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 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace common
31  {
34 
38  {
41  public: NodeAnimation(const std::string& _name);
42 
44  public: ~NodeAnimation();
45 
48  public: void SetName(const std::string& _name);
49 
52  public: std::string GetName() const;
53 
57  public: void AddKeyFrame(const double _time, const math::Matrix4 &_trans);
58 
62  public: void AddKeyFrame(const double _time, const math::Pose &_pose);
63 
66  public: unsigned int GetFrameCount() const;
67 
74  public: void GetKeyFrame(const unsigned int _i, double& _time,
75  math::Matrix4& _trans) const;
76 
82  public: std::pair<double, math::Matrix4> GetKeyFrame(
83  const unsigned int _i) const;
84 
87  public: double GetLength() const;
88 
95  public: math::Matrix4 GetFrameAt(double _time, bool _loop = true) const;
96 
100  public: void Scale(const double _scale);
101 
108  public: double GetTimeAtX(const double _x) const;
109 
111  protected: std::string name;
112 
114  protected: std::map<double, math::Matrix4> keyFrames;
115 
117  protected: double length;
118  };
119 
122  {
125  public: SkeletonAnimation(const std::string& _name);
126 
129  public: ~SkeletonAnimation();
130 
133  public: void SetName(const std::string& _name);
134 
137  public: std::string GetName() const;
138 
141  public: unsigned int GetNodeCount() const;
142 
146  public: bool HasNode(const std::string& _node) const;
147 
152  public: void AddKeyFrame(const std::string& _node, const double _time,
153  const math::Matrix4 &_mat);
154 
159  public: void AddKeyFrame(const std::string& _node, const double _time,
160  const math::Pose &_pose);
161 
171  public: math::Matrix4 GetNodePoseAt(const std::string& _node,
172  const double _time, const bool _loop = true);
173 
182  public: std::map<std::string, math::Matrix4> GetPoseAt(const double _time,
183  const bool _loop = true) const;
184 
193  public: std::map<std::string, math::Matrix4> GetPoseAtX(const double _x,
194  const std::string& _node, const bool _loop = true) const;
195 
198  public: void Scale(const double _scale);
199 
202  public: double GetLength() const;
203 
205  protected: std::string name;
206 
208  protected: double length;
209 
211  protected: std::map<std::string, NodeAnimation*> animations;
212  };
214  }
215 }
216 
217 #endif