Ignition Common

API Reference

3.14.0
SkeletonNode.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_COMMON_SKELETON_NODE_HH_
18 #define IGNITION_COMMON_SKELETON_NODE_HH_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 
25 #include <ignition/common/graphics/Export.hh>
26 
27 namespace ignition
28 {
29  namespace common
30  {
32  class SkeletonNodePrivate;
33 
36  class IGNITION_COMMON_GRAPHICS_VISIBLE SkeletonNode
37  {
39  public: enum SkeletonNodeType {NODE, JOINT};
40 
43  public: explicit SkeletonNode(SkeletonNode *_parent);
44 
50  public: SkeletonNode(SkeletonNode *_parent,
51  const std::string &_name,
52  const std::string &_id,
53  const SkeletonNodeType _type = JOINT);
54 
56  public: virtual ~SkeletonNode();
57 
60  public: void Name(const std::string &_name);
61 
64  public: std::string Name() const;
65 
68  public: void Id(const std::string &_id);
69 
72  public: std::string Id() const;
73 
76  public: void SetType(const SkeletonNodeType _type);
77 
80  public: bool IsJoint() const;
81 
86  public: void SetTransform(const math::Matrix4d &_trans,
87  const bool _updateChildren = true);
88 
93  public: void SetModelTransform(const math::Matrix4d &_trans,
94  const bool _updateChildren = true);
95 
97  public: void UpdateChildrenTransforms();
98 
101  public: void SetInitialTransform(const math::Matrix4d &_trans);
102 
106  public: void Reset(const bool _resetChildren);
107 
109  public: math::Matrix4d Transform() const;
110 
113  public: void SetParent(SkeletonNode *_parent);
114 
117  public: SkeletonNode *Parent() const;
118 
121  public: bool IsRootNode() const;
122 
125  public: void AddChild(SkeletonNode *_child);
126 
129  public: unsigned int ChildCount() const;
130 
134  public: SkeletonNode *Child(const unsigned int _index) const;
135 
139  public: SkeletonNode *ChildByName(const std::string &_name) const;
140 
144  public: SkeletonNode *ChildById(const std::string &_id) const;
145 
148  public: void Handle(const unsigned int _h);
149 
152  public: unsigned int Handle() const;
153 
156  public: void SetInverseBindTransform(const math::Matrix4d &_invBM);
157 
161 
166  public: bool HasInvBindTransform() const;
167 
171 
175 
178  public: unsigned int RawTransformCount() const;
179 
183  public: NodeTransform RawTransform(const unsigned int _i) const;
184 
187  public: void AddRawTransform(const NodeTransform &_t);
188 
192 
194  private: SkeletonNodePrivate *data;
195  };
196 
198  }
199 }
200 #endif
A transformation node.
Definition: NodeTransform.hh:37
A skeleton node.
Definition: SkeletonNode.hh:37
void Name(const std::string &_name)
Change the name.
unsigned int Handle() const
Get the handle index.
void Id(const std::string &_id)
Change the id string.
math::Matrix4d InverseBindTransform() const
Retrieve the inverse of the bind pose skeletal transform.
SkeletonNode * Parent() const
Returns the parent node.
SkeletonNode(SkeletonNode *_parent, const std::string &_name, const std::string &_id, const SkeletonNodeType _type=JOINT)
Constructor.
bool IsJoint() const
Is a joint query.
void SetModelTransform(const math::Matrix4d &_trans, const bool _updateChildren=true)
Set the model transformation.
bool IsRootNode() const
Queries wether a node has no parent parent.
std::string Name() const
Returns the name.
SkeletonNode * Child(const unsigned int _index) const
Find a child by index.
void UpdateChildrenTransforms()
Apply model transformations in order for each node in the tree.
SkeletonNode * ChildByName(const std::string &_name) const
Get child by name.
unsigned int RawTransformCount() const
Return the raw transformations count.
SkeletonNode(SkeletonNode *_parent)
Constructor.
void SetTransform(const math::Matrix4d &_trans, const bool _updateChildren=true)
Set a transformation.
NodeTransform RawTransform(const unsigned int _i) const
Find a raw transformation.
bool HasInvBindTransform() const
Returns true if the node has inv bind transform. \detail to keep ABI compatibility,...
std::vector< NodeTransform > Transforms() const
Returns a copy of the array of transformations.
virtual ~SkeletonNode()
Destructor.
void SetType(const SkeletonNodeType _type)
Change the skeleton node type.
math::Matrix4d ModelTransform() const
Retrieve the model transform.
math::Matrix4d Transform() const
Get transform relative to parent.
SkeletonNodeType
enumeration of node types
Definition: SkeletonNode.hh:39
void AddChild(SkeletonNode *_child)
Add a new child.
SkeletonNode * ChildById(const std::string &_id) const
Get child by string id.
void SetParent(SkeletonNode *_parent)
Set the parent node.
void AddRawTransform(const NodeTransform &_t)
Add a raw transform.
void Reset(const bool _resetChildren)
Reset the transformation to the initial transformation.
std::vector< NodeTransform > RawTransforms() const
Retrieve the raw transformations.
unsigned int ChildCount() const
Returns the children count.
void SetInverseBindTransform(const math::Matrix4d &_invBM)
Assign the inverse of the bind pose skeletal transform.
std::string Id() const
Returns the index.
void Handle(const unsigned int _h)
Assign a handle number.
void SetInitialTransform(const math::Matrix4d &_trans)
Sets the initial transformation.
std::map< unsigned int, SkeletonNode * > SkeletonNodeMap
Definition: SkeletonNode.hh:197
Forward declarations for the common classes.