SkeletonAnimation.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 _GAZEBO_SKELETONANIMATION_HH_
18 #define _GAZEBO_SKELETONANIMATION_HH_
19 
20 #include <map>
21 #include <utility>
22 #include <string>
23 
24 #include <ignition/math/Matrix4.hh>
25 #include <ignition/math/Pose3.hh>
26 
27 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace common
33  {
36 
39  class GZ_COMMON_VISIBLE NodeAnimation
40  {
43  public: explicit NodeAnimation(const std::string &_name);
44 
46  public: ~NodeAnimation();
47 
50  public: void SetName(const std::string &_name);
51 
54  public: std::string GetName() const;
55 
59  public: void AddKeyFrame(const double _time,
60  const ignition::math::Matrix4d &_trans);
61 
65  public: void AddKeyFrame(const double _time,
66  const ignition::math::Pose3d &_pose);
67 
70  public: unsigned int GetFrameCount() const;
71 
78  public: void GetKeyFrame(const unsigned int _i, double &_time,
79  ignition::math::Matrix4d &_trans) const;
80 
86  public: std::pair<double, ignition::math::Matrix4d> KeyFrame(
87  const unsigned int _i) const;
88 
91  public: double GetLength() const;
92 
99  public: ignition::math::Matrix4d FrameAt(
100  double _time, bool _loop = true) const;
101 
105  public: void Scale(const double _scale);
106 
113  public: double GetTimeAtX(const double _x) const;
114 
116  protected: std::string name;
117 
119  protected: std::map<double, ignition::math::Matrix4d> keyFrames;
120 
122  protected: double length;
123  };
124 
126  class GZ_COMMON_VISIBLE SkeletonAnimation
127  {
130  public: explicit SkeletonAnimation(const std::string &_name);
131 
134  public: ~SkeletonAnimation();
135 
138  public: void SetName(const std::string &_name);
139 
142  public: std::string GetName() const;
143 
146  public: unsigned int GetNodeCount() const;
147 
151  public: bool HasNode(const std::string &_node) const;
152 
157  public: void AddKeyFrame(const std::string &_node, const double _time,
158  const ignition::math::Matrix4d &_mat);
159 
165  public: void AddKeyFrame(const std::string &_node, const double _time,
166  const ignition::math::Pose3d &_pose);
167 
177  public: ignition::math::Matrix4d NodePoseAt(const std::string &_node,
178  const double _time, const bool _loop = true);
179 
188  public: std::map<std::string, ignition::math::Matrix4d> PoseAt(
189  const double _time, const bool _loop = true) const;
190 
199  public: std::map<std::string, ignition::math::Matrix4d> PoseAtX(
200  const double _x, const std::string &_node,
201  const bool _loop = true) const;
202 
203 
206  public: void Scale(const double _scale);
207 
210  public: double GetLength() const;
211 
213  protected: std::string name;
214 
216  protected: double length;
217 
219  protected: std::map<std::string, NodeAnimation*> animations;
220  };
222  }
223 }
224 
225 #endif
double length
the duration of the longest animation
Definition: SkeletonAnimation.hh:216
Skeleton animation.
Definition: SkeletonAnimation.hh:126
std::map< double, ignition::math::Matrix4d > keyFrames
the dictionary of key frames, indexed by time
Definition: SkeletonAnimation.hh:119
std::string name
the node name
Definition: SkeletonAnimation.hh:213
std::map< std::string, NodeAnimation * > animations
a dictionary of node animations
Definition: SkeletonAnimation.hh:219
A key frame in an animation.
Definition: KeyFrame.hh:35
std::string name
the name of the animation
Definition: SkeletonAnimation.hh:116
double length
the duration of the animations (time of last key frame)
Definition: SkeletonAnimation.hh:122
Node animation.
Definition: SkeletonAnimation.hh:39