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 (C) 2012-2014 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 _SKELETONANIMATION_HH_
18 #define _SKELETONANIMATION_HH_
19 
20 #include <map>
21 #include <utility>
22 #include <string>
23 
24 #include "gazebo/math/Matrix4.hh"
25 #include "gazebo/math/Pose.hh"
26 
27 namespace gazebo
28 {
29  namespace common
30  {
33 
37  {
40  public: NodeAnimation(const std::string& _name);
41 
43  public: ~NodeAnimation();
44 
47  public: void SetName(const std::string& _name);
48 
51  public: std::string GetName() const;
52 
56  public: void AddKeyFrame(const double _time, const math::Matrix4 _trans);
57 
61  public: void AddKeyFrame(const double _time, const math::Pose _pose);
62 
65  public: unsigned int GetFrameCount() const;
66 
73  public: void GetKeyFrame(const unsigned int _i, double& _time,
74  math::Matrix4& _trans) const;
75 
81  public: std::pair<double, math::Matrix4> GetKeyFrame(
82  const unsigned int _i) const;
83 
86  public: double GetLength() const;
87 
94  public: math::Matrix4 GetFrameAt(double _time, bool _loop = true) const;
95 
99  public: void Scale(const double _scale);
100 
107  public: double GetTimeAtX(const double _x) const;
108 
110  protected: std::string name;
111 
113  protected: std::map<double, math::Matrix4> keyFrames;
114 
116  protected: double length;
117  };
118 
121  {
124  public: SkeletonAnimation(const std::string& _name);
125 
128  public: ~SkeletonAnimation();
129 
132  public: void SetName(const std::string& _name);
133 
136  public: std::string GetName() const;
137 
140  public: unsigned int GetNodeCount() const;
141 
145  public: bool HasNode(const std::string& _node) const;
146 
151  public: void AddKeyFrame(const std::string& _node, const double _time,
152  const math::Matrix4 _mat);
153 
158  public: void AddKeyFrame(const std::string& _node, const double _time,
159  const math::Pose _pose);
160 
170  public: math::Matrix4 GetNodePoseAt(const std::string& _node,
171  const double _time, const bool _loop = true);
172 
181  public: std::map<std::string, math::Matrix4> GetPoseAt(const double _time,
182  const bool _loop = true) const;
183 
192  public: std::map<std::string, math::Matrix4> GetPoseAtX(const double _x,
193  const std::string& _node, const bool _loop = true) const;
194 
197  public: void Scale(const double _scale);
198 
201  public: double GetLength() const;
202 
204  protected: std::string name;
205 
207  protected: double length;
208 
210  protected: std::map<std::string, NodeAnimation*> animations;
211  };
213  }
214 }
215 
216 #endif