All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SkeletonAnimation.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Nate Koenig
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 _SKELETONANIMATION_HH_
18 #define _SKELETONANIMATION_HH_
19 
20 #include <math/Matrix4.hh>
21 #include <math/Pose.hh>
22 
23 #include <map>
24 #include <utility>
25 #include <string>
26 
27 namespace gazebo
28 {
29  namespace common
30  {
33 
36  {
39  public: NodeAnimation(const std::string& _name);
40 
42  public: ~NodeAnimation();
43 
46  public: void SetName(const std::string& _name);
47 
50  public: std::string GetName() const;
51 
55  public: void AddKeyFrame(const double _time, const math::Matrix4 _trans);
56 
60  public: void AddKeyFrame(const double _time, const math::Pose _pose);
61 
64  public: unsigned int GetFrameCount() const;
65 
72  public: void GetKeyFrame(const unsigned int _i, double& _time,
73  math::Matrix4& _trans) const;
74 
80  public: std::pair<double, math::Matrix4> GetKeyFrame(
81  const unsigned int _i) const;
82 
85  public: double GetLength() const;
86 
93  public: math::Matrix4 GetFrameAt(double _time, bool _loop = true) const;
94 
98  public: void Scale(const double _scale);
99 
106  public: double GetTimeAtX(const double _x) const;
107 
109  protected: std::string name;
110 
112  protected: std::map<double, math::Matrix4> keyFrames;
113 
115  protected: double length;
116  };
117 
120  {
123  public: SkeletonAnimation(const std::string& _name);
124 
127  public: ~SkeletonAnimation();
128 
131  public: void SetName(const std::string& _name);
132 
135  public: std::string GetName() const;
136 
139  public: unsigned int GetNodeCount() const;
140 
144  public: bool HasNode(const std::string& _node) const;
145 
150  public: void AddKeyFrame(const std::string& _node, const double _time,
151  const math::Matrix4 _mat);
152 
157  public: void AddKeyFrame(const std::string& _node, const double _time,
158  const math::Pose _pose);
159 
169  public: math::Matrix4 GetNodePoseAt(const std::string& _node,
170  const double _time, const bool _loop = true);
171 
180  public: std::map<std::string, math::Matrix4> GetPoseAt(const double _time,
181  const bool _loop = true) const;
182 
191  public: std::map<std::string, math::Matrix4> GetPoseAtX(const double _x,
192  const std::string& _node, const bool _loop = true) const;
193 
196  public: void Scale(const double _scale);
197 
200  public: double GetLength() const;
201 
203  protected: std::string name;
204 
206  protected: double length;
207 
209  protected: std::map<std::string, NodeAnimation*> animations;
210  };
212  }
213 }
214 
215 #endif