Go to the documentation of this file.
17 #ifndef GAZEBO_COMMON_SKELETON_HH_
18 #define GAZEBO_COMMON_SKELETON_HH_
25 #include <ignition/math/Matrix4.hh>
38 typedef std::map<unsigned int, SkeletonNode*>
NodeMap;
39 typedef std::map<unsigned int, SkeletonNode*>::iterator
NodeMapIter;
41 typedef std::map<double, std::vector<NodeTransform> >
RawNodeAnim;
44 typedef std::vector<std::vector<std::pair<std::string, double> > >
85 public:
SkeletonNode* GetNodeByHandle(
unsigned int _handle);
89 public:
unsigned int GetNumNodes();
93 public:
unsigned int GetNumJoints();
97 public:
void Scale(
double _scale);
101 public:
void SetBindShapeTransform(
102 const ignition::math::Matrix4d &_trans);
106 public: ignition::math::Matrix4d BindShapeTransform();
109 public:
void PrintTransforms();
116 public:
void SetNumVertAttached(
unsigned int _vertices);
122 public:
void AddVertNodeWeight(
unsigned int _vertex, std::string _node,
128 public:
unsigned int GetNumVertNodeWeights(
unsigned int _vertex);
134 public: std::pair<std::string, double> GetVertNodeWeight(
unsigned int _v,
139 public:
unsigned int GetNumAnimations();
153 protected:
void BuildNodeMap();
168 protected: std::vector<SkeletonAnimation*>
anims;
188 std::string _id, SkeletonNodeType _type = JOINT);
195 public:
void SetName(std::string _name);
199 public: std::string GetName();
203 public:
void SetId(std::string _id);
207 public: std::string GetId();
211 public:
void SetType(SkeletonNodeType _type);
215 public:
bool IsJoint();
221 public:
void SetTransform(
const ignition::math::Matrix4d &_trans,
222 bool _updateChildren =
true);
228 public:
void SetModelTransform(
const ignition::math::Matrix4d &_trans,
229 bool _updateChildren =
true);
232 public:
void UpdateChildrenTransforms();
236 public:
void SetInitialTransform(
const ignition::math::Matrix4d &_tras);
241 public:
void Reset(
bool _resetChildren);
245 public: ignition::math::Matrix4d Transform();
257 public:
bool IsRootNode();
265 public:
unsigned int GetChildCount();
275 public:
SkeletonNode* GetChildByName(std::string _name);
284 public:
void SetHandle(
unsigned int _h);
288 public:
unsigned int GetHandle();
292 public:
void SetInverseBindTransform(
293 const ignition::math::Matrix4d &_invBM);
297 public: ignition::math::Matrix4d InverseBindTransform();
301 public: ignition::math::Matrix4d ModelTransform()
const;
305 public: std::vector<NodeTransform> GetRawTransforms();
309 public:
unsigned int GetNumRawTrans();
322 public: std::vector<NodeTransform> GetTransforms();
328 protected: std::string
id;
367 public:
explicit NodeTransform(TransformType _type = MATRIX);
374 const std::string &_sid =
"_default_",
375 TransformType _type = MATRIX);
382 public:
void Set(
const ignition::math::Matrix4d &_mat);
386 public:
void SetType(TransformType _type);
390 public:
void SetSID(std::string _sid);
394 public: ignition::math::Matrix4d GetTransform()
const;
398 public: TransformType GetType();
402 public: std::string GetSID();
407 public:
void SetComponent(
unsigned int _idx,
double _value);
411 public:
void SetSourceValues(
const ignition::math::Matrix4d &_mat);
415 public:
void SetSourceValues(
const ignition::math::Vector3d &_vec);
420 public:
void SetSourceValues(
const ignition::math::Vector3d &_axis,
421 const double _angle);
424 public:
void RecalculateMatrix();
427 public:
void PrintSource();
431 public: ignition::math::Matrix4d operator()();
436 public: ignition::math::Matrix4d operator*(
NodeTransform _t);
441 public: ignition::math::Matrix4d operator*(
442 const ignition::math::Matrix4d &_m);
445 protected: std::string
sid;
void SetType(SkeletonNodeType _type)
Change the skeleton node type.
ignition::math::Matrix4d bindShapeTransform
the bind pose skeletal transform
Definition: Skeleton.hh:162
std::map< unsigned int, SkeletonNode * > NodeMap
Definition: Skeleton.hh:36
void PrintTransforms()
Outputs the transforms to std::err stream.
std::string GetId()
Returns the index.
SkeletonNodeType type
the type fo node
Definition: Skeleton.hh:331
void BuildNodeMap()
Initializes the hande numbers for each node in the map using breadth first traversal.
RawNodeWeights rawNW
the node weight table
Definition: Skeleton.hh:165
std::vector< NodeTransform > rawTransforms
the raw transformation
Definition: Skeleton.hh:355
Forward declarations for the common classes.
Definition: Animation.hh:26
NodeTransform GetRawTransform(unsigned int _i)
Find a raw transformation.
std::map< std::string, RawNodeAnim > RawSkeletonAnim
Definition: Skeleton.hh:42
void SetTransform(const ignition::math::Matrix4d &_trans, bool _updateChildren=true)
Set a transformation.
std::map< double, std::vector< NodeTransform > > RawNodeAnim
Definition: Skeleton.hh:41
SkeletonNode * root
the root node
Definition: Skeleton.hh:156
void SetName(std::string _name)
Change the name.
Definition: Skeleton.hh:176
NodeMap nodes
The dictionary of nodes, indexed by name.
Definition: Skeleton.hh:159
void AddRawTransform(NodeTransform _t)
Add a raw transform.
Definition: Skeleton.hh:176
SkeletonNode * GetRootNode()
Return the root.
void SetNumVertAttached(unsigned int _vertices)
Resizes the raw node weight array.
ignition::math::Matrix4d initialTransform
the initial transformation
Definition: Skeleton.hh:337
std::pair< std::string, double > GetVertNodeWeight(unsigned int _v, unsigned int _i)
Weight of a bone for a vertex.
ignition::math::Matrix4d modelTransform
the model transformation
Definition: Skeleton.hh:340
virtual ~Skeleton()
Destructor.
ignition::math::Matrix4d transform
the transform
Definition: Skeleton.hh:334
SkeletonNode * parent
the parent node
Definition: Skeleton.hh:346
std::string GetName()
Returns the name.
SkeletonNode * GetChild(unsigned int _index)
Find a child by index.
bool IsRootNode()
Queries wether a node has no parent parent.
Skeleton animation.
Definition: SkeletonAnimation.hh:126
void AddAnimation(SkeletonAnimation *_anim)
Add an animation.
void SetInverseBindTransform(const ignition::math::Matrix4d &_invBM)
Assign the inverse of the bind pose skeletal transform.
SkeletonAnimation * GetAnimation(const unsigned int _i)
Find animation.
A skeleton.
Definition: Skeleton.hh:52
std::vector< SkeletonNode * > children
the children nodes
Definition: Skeleton.hh:349
std::string id
a string identifier
Definition: Skeleton.hh:328
void SetInitialTransform(const ignition::math::Matrix4d &_tras)
Sets the initial transformation.
unsigned int GetNumAnimations()
Returns the number of animations.
ignition::math::Matrix4d InverseBindTransform()
Retrieve the inverse of the bind pose skeletal transform.
SkeletonNode * GetNodeByHandle(unsigned int _handle)
Find or create node with handle.
SkeletonNode * GetChildByName(std::string _name)
Get child by name.
ignition::math::Matrix4d ModelTransform() const
Retrieve the model transform.
void Scale(double _scale)
Scale all nodes, transforms and animation data.
ignition::math::Matrix4d BindShapeTransform()
Return bind pose skeletal transform.
unsigned int GetNumVertNodeWeights(unsigned int _vertex)
Returns the number of bone weights for a vertex.
void UpdateChildrenTransforms()
Apply model transformations in order for each node in the tree.
SkeletonNode * GetNodeById(std::string _id)
Find node by index.
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
void SetHandle(unsigned int _h)
Assign a handle number.
bool IsJoint()
Is a joint query.
unsigned int GetNumNodes()
Returns the node count.
SkeletonNodeType
enumeration of node types
Definition: Skeleton.hh:176
SkeletonNode * GetChildById(std::string _id)
Get child by string id.
SkeletonNode(SkeletonNode *_parent)
Constructor.
SkeletonNode * GetParent()
Returns the parent node.
virtual ~SkeletonNode()
Destructor.
unsigned int GetNumRawTrans()
Return the raw transformations count.
void AddChild(SkeletonNode *_child)
Add a new child.
std::vector< NodeTransform > GetRawTransforms()
Retrieve the raw transformations.
void SetModelTransform(const ignition::math::Matrix4d &_trans, bool _updateChildren=true)
Set the model transformation.
std::string name
the name of the skeletal node
Definition: Skeleton.hh:325
std::vector< std::vector< std::pair< std::string, double > > > RawNodeWeights
Definition: Skeleton.hh:45
unsigned int handle
handle index number
Definition: Skeleton.hh:352
ignition::math::Matrix4d Transform()
Get transform relative to parent.
NodeMap GetNodes()
Get a copy or the node dictionary.
void SetParent(SkeletonNode *_parent)
Set the parent node.
ignition::math::Matrix4d invBindTransform
the inverse of the bind pose skeletal transform
Definition: Skeleton.hh:343
A skeleton node.
Definition: Skeleton.hh:173
unsigned int GetHandle()
Get the handle index.
void SetBindShapeTransform(const ignition::math::Matrix4d &_trans)
Set the bind pose skeletal transform.
unsigned int GetNumJoints()
Returns the number of joints.
std::vector< NodeTransform > GetTransforms()
Returns a copy of the array of transformations.
std::vector< SkeletonAnimation * > anims
the array of animations
Definition: Skeleton.hh:168
unsigned int GetChildCount()
Returns the children count.
void AddVertNodeWeight(unsigned int _vertex, std::string _node, double _weight)
Add a new weight to a node (bone)
std::map< unsigned int, SkeletonNode * >::iterator NodeMapIter
Definition: Skeleton.hh:39
SkeletonNode * GetNodeByName(std::string _name)
Find a node.
void SetRootNode(SkeletonNode *_node)
Change the root node.
void Reset(bool _resetChildren)
Reset the transformation to the initial transformation.
void SetId(std::string _id)
Change the id string.