17#ifndef GAZEBO_COMMON_SKELETON_HH_
18#define GAZEBO_COMMON_SKELETON_HH_
25#include <ignition/math/Matrix4.hh>
36 class SkeletonAnimation;
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> > >
106 const ignition::math::Matrix4d &_trans);
167 protected: ignition::math::Matrix4d bindShapeTransform =
168 ignition::math::Matrix4d::Identity;
174 protected: std::vector<SkeletonAnimation*>
anims;
214 public: std::string
Name()
const;
218 public:
void SetId(std::string _id);
237 bool _updateChildren =
true);
244 bool _updateChildren =
true);
256 public:
void Reset(
bool _resetChildren);
308 const ignition::math::Matrix4d &_invBM);
349 protected: std::string
id;
395 const std::string &_sid =
"_default_",
403 public:
void Set(
const ignition::math::Matrix4d &_mat);
442 const double _angle);
463 const ignition::math::Matrix4d &_m);
466 protected: std::string
sid;
common
Definition FuelModelDatabase.hh:37
Skeleton animation.
Definition SkeletonAnimation.hh:127
A skeleton node.
Definition Skeleton.hh:180
void Reset(bool _resetChildren)
Reset the transformation to the initial transformation.
std::vector< NodeTransform > rawTransforms
the raw transformation
Definition Skeleton.hh:376
void AddRawTransform(NodeTransform _t)
Add a raw transform.
std::vector< NodeTransform > GetRawTransforms()
Retrieve the raw transformations.
void SetName(std::string _name)
Change the name.
std::vector< SkeletonNode * > children
the children nodes
Definition Skeleton.hh:370
ignition::math::Matrix4d modelTransform
the model transformation
Definition Skeleton.hh:361
void SetTransform(const ignition::math::Matrix4d &_trans, bool _updateChildren=true)
Set a transformation.
SkeletonNodeType type
the type fo node
Definition Skeleton.hh:352
SkeletonNode * parent
the parent node
Definition Skeleton.hh:367
bool IsJoint()
Is a joint query.
SkeletonNode * GetChildByName(std::string _name)
Get child by name.
bool IsRootNode()
Queries wether a node has no parent parent.
ignition::math::Matrix4d transform
the transform
Definition Skeleton.hh:355
std::string Name() const
Returns the name.
void SetType(SkeletonNodeType _type)
Change the skeleton node type.
void SetModelTransform(const ignition::math::Matrix4d &_trans, bool _updateChildren=true)
Set the model transformation.
SkeletonNode * GetChildById(std::string _id)
Get child by string id.
void SetId(std::string _id)
Change the id string.
void UpdateChildrenTransforms()
Apply model transformations in order for each node in the tree.
void SetInitialTransform(const ignition::math::Matrix4d &_tras)
Sets the initial transformation.
SkeletonNode(SkeletonNode *_parent)
Constructor.
std::vector< NodeTransform > GetTransforms()
Returns a copy of the array of transformations.
ignition::math::Matrix4d ModelTransform() const
Retrieve the model transform.
unsigned int handle
handle index number
Definition Skeleton.hh:373
void SetHandle(unsigned int _h)
Assign a handle number.
std::string GetName()
Returns the name.
virtual ~SkeletonNode()
Destructor.
unsigned int GetNumRawTrans()
Return the raw transformations count.
SkeletonNode * GetChild(unsigned int _index)
Find a child by index.
std::string name
the name of the skeletal node
Definition Skeleton.hh:346
ignition::math::Matrix4d Transform()
Get transform relative to parent.
ignition::math::Matrix4d initialTransform
the initial transformation
Definition Skeleton.hh:358
unsigned int GetHandle()
Get the handle index.
NodeTransform GetRawTransform(unsigned int _i)
Find a raw transformation.
ignition::math::Matrix4d invBindTransform
the inverse of the bind pose skeletal transform
Definition Skeleton.hh:364
unsigned int GetChildCount()
Returns the children count.
SkeletonNodeType
enumeration of node types
Definition Skeleton.hh:182
@ NODE
Definition Skeleton.hh:182
@ JOINT
Definition Skeleton.hh:182
void AddChild(SkeletonNode *_child)
Add a new child.
SkeletonNode(SkeletonNode *_parent, std::string _name, std::string _id, SkeletonNodeType _type=JOINT)
Constructor.
void SetParent(SkeletonNode *_parent)
Set the parent node.
void SetInverseBindTransform(const ignition::math::Matrix4d &_invBM)
Assign the inverse of the bind pose skeletal transform.
SkeletonNode * GetParent()
Returns the parent node.
std::string GetId()
Returns the index.
bool HasInvBindTransform()
returns true if the node has inv bind transform.
std::string id
a string identifier
Definition Skeleton.hh:349
ignition::math::Matrix4d InverseBindTransform()
Retrieve the inverse of the bind pose skeletal transform.
A skeleton.
Definition Skeleton.hh:53
SkeletonNode * GetNodeById(std::string _id)
Find node by index.
SkeletonNode * GetNodeByName(std::string _name)
Find a node.
SkeletonNode * GetNodeByHandle(unsigned int _handle)
Find or create node with handle.
void SetRootNode(SkeletonNode *_node)
Change the root node.
unsigned int GetNumNodes()
Returns the node count.
RawNodeWeights rawNW
the node weight table
Definition Skeleton.hh:171
unsigned int GetNumVertNodeWeights(unsigned int _vertex)
Returns the number of bone weights for a vertex.
SkeletonAnimation * GetAnimation(const unsigned int _i)
Find animation.
const SkeletonNode * GetRootNode() const
Return the root.
unsigned int GetNumJoints()
Returns the number of joints.
ignition::math::Matrix4d bindShapeTransform
the bind pose skeletal transform
Definition Skeleton.hh:167
void AddAnimation(SkeletonAnimation *_anim)
Add an animation.
virtual ~Skeleton()
Destructor.
ignition::math::Matrix4d BindShapeTransform()
Return bind pose skeletal transform.
std::pair< std::string, double > GetVertNodeWeight(unsigned int _v, unsigned int _i)
Weight of a bone for a vertex.
void BuildNodeMap()
Initializes the hande numbers for each node in the map using breadth first traversal.
Skeleton(SkeletonNode *_root)
Constructor.
unsigned int GetNumAnimations()
Returns the number of animations.
void SetBindShapeTransform(const ignition::math::Matrix4d &_trans)
Set the bind pose skeletal transform.
NodeMap GetNodes()
Get a copy or the node dictionary.
SkeletonNode * GetRootNode()
Return the root.
void Scale(double _scale)
Scale all nodes, transforms and animation data.
void PrintTransforms()
Outputs the transforms to std::err stream.
void SetNumVertAttached(unsigned int _vertices)
Resizes the raw node weight array, this also clears all the node weights assigned.
void AddVertNodeWeight(unsigned int _vertex, std::string _node, double _weight)
Add a new weight to a node (bone)
std::vector< SkeletonAnimation * > anims
the array of animations
Definition Skeleton.hh:174
SkeletonNode * root
the root node
Definition Skeleton.hh:161
NodeMap nodes
The dictionary of nodes, indexed by name.
Definition Skeleton.hh:164
std::map< unsigned int, SkeletonNode * > NodeMap
Definition Skeleton.hh:38
std::map< double, std::vector< NodeTransform > > RawNodeAnim
Definition Skeleton.hh:41
std::map< unsignedint, SkeletonNode * >::iterator NodeMapIter
Definition Skeleton.hh:39
std::vector< std::vector< std::pair< std::string, double > > > RawNodeWeights
Definition Skeleton.hh:45
std::map< std::string, RawNodeAnim > RawSkeletonAnim
Definition Skeleton.hh:42
Forward declarations for the common classes.
Definition Animation.hh:27