Gazebo Common

API Reference

5.6.0
gz/common/Skeleton.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 GZ_COMMON_SKELETON_HH_
18 #define GZ_COMMON_SKELETON_HH_
19 
20 #include <vector>
21 #include <string>
22 #include <map>
23 #include <utility>
24 
25 #include <gz/math/Matrix4.hh>
26 
27 #include <gz/utils/ImplPtr.hh>
28 
30 #include <gz/common/graphics/Export.hh>
31 
32 namespace gz
33 {
34  namespace common
35  {
36  class SkeletonAnimation;
37 
40  class GZ_COMMON_GRAPHICS_VISIBLE Skeleton
41  {
43  public: Skeleton();
44 
47  public: explicit Skeleton(SkeletonNode *_root);
48 
50  public: virtual ~Skeleton();
51 
54  public: void RootNode(SkeletonNode *_node);
55 
58  public: SkeletonNode *RootNode() const;
59 
63  public: SkeletonNode *NodeByName(const std::string &_name) const;
64 
68  public: SkeletonNode *NodeById(const std::string &_id) const;
69 
73  public: SkeletonNode *NodeByHandle(const unsigned int _handle) const;
74 
77  public: unsigned int NodeCount() const;
78 
81  public: unsigned int JointCount() const;
82 
85  public: void Scale(const double _scale);
86 
89  public: void SetBindShapeTransform(const math::Matrix4d &_trans);
90 
94 
96  public: void PrintTransforms() const;
97 
100  public: const SkeletonNodeMap &Nodes() const;
101 
104  public: void SetNumVertAttached(const unsigned int _vertices);
105 
110  public: void AddVertNodeWeight(const unsigned int _vertex,
111  const std::string &_node, const double _weight);
112 
116  public: unsigned int VertNodeWeightCount(
117  const unsigned int _vertex) const;
118 
124  const unsigned int _v, const unsigned int _i) const;
125 
128  public: unsigned int AnimationCount() const;
129 
133  public: SkeletonAnimation *Animation(const unsigned int _i) const;
134 
138  public: void AddAnimation(SkeletonAnimation *_anim);
139 
144  public: bool AddBvhAnimation(const std::string &_bvhFile, double _scale);
145 
151  public: std::string NodeNameAnimToSkin(unsigned int _index,
152  const std::string &_animNodeName);
153 
159  public: math::Matrix4d AlignTranslation(unsigned int _index,
160  const std::string &_animNodeName);
161 
167  public: math::Matrix4d AlignRotation(unsigned int _index,
168  const std::string &_animNodeName);
169 
172  private: void BuildNodeMap();
173 
175  GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
176  };
177  }
178 }
179 #endif