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> > >
89 public:
SkeletonNode* GetNodeByHandle(
unsigned int _handle);
93 public:
unsigned int GetNumNodes();
97 public:
unsigned int GetNumJoints();
101 public:
void Scale(
double _scale);
105 public:
void SetBindShapeTransform(
106 const ignition::math::Matrix4d &_trans);
110 public: ignition::math::Matrix4d BindShapeTransform();
113 public:
void PrintTransforms();
121 public:
void SetNumVertAttached(
unsigned int _vertices);
127 public:
void AddVertNodeWeight(
unsigned int _vertex, std::string _node,
133 public:
unsigned int GetNumVertNodeWeights(
unsigned int _vertex);
139 public: std::pair<std::string, double> GetVertNodeWeight(
unsigned int _v,
144 public:
unsigned int GetNumAnimations();
158 protected:
void BuildNodeMap();
167 protected: ignition::math::Matrix4d bindShapeTransform =
168 ignition::math::Matrix4d::Identity;
174 protected: std::vector<SkeletonAnimation*>
anims;
194 std::string _id, SkeletonNodeType _type = JOINT);
201 public:
void SetName(std::string _name);
207 public: std::string GetName();
214 public: std::string Name()
const;
218 public:
void SetId(std::string _id);
222 public: std::string GetId();
226 public:
void SetType(SkeletonNodeType _type);
230 public:
bool IsJoint();
236 public:
void SetTransform(
const ignition::math::Matrix4d &_trans,
237 bool _updateChildren =
true);
243 public:
void SetModelTransform(
const ignition::math::Matrix4d &_trans,
244 bool _updateChildren =
true);
247 public:
void UpdateChildrenTransforms();
251 public:
void SetInitialTransform(
const ignition::math::Matrix4d &_tras);
256 public:
void Reset(
bool _resetChildren);
260 public: ignition::math::Matrix4d Transform();
272 public:
bool IsRootNode();
280 public:
unsigned int GetChildCount();
290 public:
SkeletonNode* GetChildByName(std::string _name);
299 public:
void SetHandle(
unsigned int _h);
303 public:
unsigned int GetHandle();
307 public:
void SetInverseBindTransform(
308 const ignition::math::Matrix4d &_invBM);
312 public: ignition::math::Matrix4d InverseBindTransform();
318 public:
bool HasInvBindTransform();
322 public: ignition::math::Matrix4d ModelTransform()
const;
326 public: std::vector<NodeTransform> GetRawTransforms();
330 public:
unsigned int GetNumRawTrans();
343 public: std::vector<NodeTransform> GetTransforms();
349 protected: std::string
id;
388 public:
explicit NodeTransform(TransformType _type = MATRIX);
395 const std::string &_sid =
"_default_",
396 TransformType _type = MATRIX);
403 public:
void Set(
const ignition::math::Matrix4d &_mat);
407 public:
void SetType(TransformType _type);
411 public:
void SetSID(std::string _sid);
415 public: ignition::math::Matrix4d GetTransform()
const;
419 public: TransformType GetType();
423 public: std::string GetSID();
428 public:
void SetComponent(
unsigned int _idx,
double _value);
432 public:
void SetSourceValues(
const ignition::math::Matrix4d &_mat);
436 public:
void SetSourceValues(
const ignition::math::Vector3d &_vec);
441 public:
void SetSourceValues(
const ignition::math::Vector3d &_axis,
442 const double _angle);
445 public:
void RecalculateMatrix();
448 public:
void PrintSource();
452 public: ignition::math::Matrix4d operator()();
457 public: ignition::math::Matrix4d operator*(
NodeTransform _t);
462 public: ignition::math::Matrix4d operator*(
463 const ignition::math::Matrix4d &_m);
466 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:167
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:352
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:171
std::vector< NodeTransform > rawTransforms
the raw transformation
Definition: Skeleton.hh:376
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:161
void SetName(std::string _name)
Change the name.
common
Definition: FuelModelDatabase.hh:37
std::string Name() const
Returns the name.
@ JOINT
Definition: Skeleton.hh:182
NodeMap nodes
The dictionary of nodes, indexed by name.
Definition: Skeleton.hh:164
void AddRawTransform(NodeTransform _t)
Add a raw transform.
@ NODE
Definition: Skeleton.hh:182
SkeletonNode * GetRootNode()
Return the root.
void SetNumVertAttached(unsigned int _vertices)
Resizes the raw node weight array, this also clears all the node weights assigned.
ignition::math::Matrix4d initialTransform
the initial transformation
Definition: Skeleton.hh:358
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:361
virtual ~Skeleton()
Destructor.
ignition::math::Matrix4d transform
the transform
Definition: Skeleton.hh:355
SkeletonNode * parent
the parent node
Definition: Skeleton.hh:367
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:370
std::string id
a string identifier
Definition: Skeleton.hh:349
void SetInitialTransform(const ignition::math::Matrix4d &_tras)
Sets the initial transformation.
bool HasInvBindTransform()
returns true if the node has inv bind transform.
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:182
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:346
std::vector< std::vector< std::pair< std::string, double > > > RawNodeWeights
Definition: Skeleton.hh:45
unsigned int handle
handle index number
Definition: Skeleton.hh:373
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:364
A skeleton node.
Definition: Skeleton.hh:179
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:174
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.