SkeletonAnimation.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-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 _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/math/Matrix4.hh"
28 #include "gazebo/math/Pose.hh"
29 #include "gazebo/util/system.hh"
31 
32 namespace gazebo
33 {
34  namespace common
35  {
38 
41  class GZ_COMMON_VISIBLE NodeAnimation
42  {
45  public: NodeAnimation(const std::string &_name);
46 
48  public: ~NodeAnimation();
49 
52  public: void SetName(const std::string &_name);
53 
56  public: std::string GetName() const;
57 
61  public: void AddKeyFrame(const double _time,
62  const ignition::math::Matrix4d &_trans);
63 
67  public: void AddKeyFrame(const double _time,
68  const ignition::math::Pose3d &_pose);
69 
72  public: unsigned int GetFrameCount() const;
73 
80  public: void GetKeyFrame(const unsigned int _i, double &_time,
81  ignition::math::Matrix4d &_trans) const;
82 
88  public: std::pair<double, ignition::math::Matrix4d> KeyFrame(
89  const unsigned int _i) const;
90 
93  public: double GetLength() const;
94 
101  public: ignition::math::Matrix4d FrameAt(
102  double _time, bool _loop = true) const;
103 
107  public: void Scale(const double _scale);
108 
115  public: double GetTimeAtX(const double _x) const;
116 
118  protected: std::string name;
119 
121  protected: std::map<double, ignition::math::Matrix4d> keyFrames;
122 
124  protected: double length;
125  };
126 
128  class GZ_COMMON_VISIBLE SkeletonAnimation
129  {
132  public: SkeletonAnimation(const std::string &_name);
133 
136  public: ~SkeletonAnimation();
137 
140  public: void SetName(const std::string &_name);
141 
144  public: std::string GetName() const;
145 
148  public: unsigned int GetNodeCount() const;
149 
153  public: bool HasNode(const std::string &_node) const;
154 
159  public: void AddKeyFrame(const std::string &_node, const double _time,
160  const ignition::math::Matrix4d &_mat);
161 
167  public: void AddKeyFrame(const std::string &_node, const double _time,
168  const ignition::math::Pose3d &_pose);
169 
179  public: ignition::math::Matrix4d NodePoseAt(const std::string &_node,
180  const double _time, const bool _loop = true);
181 
190  public: std::map<std::string, ignition::math::Matrix4d> PoseAt(
191  const double _time, const bool _loop = true) const;
192 
201  public: std::map<std::string, ignition::math::Matrix4d> PoseAtX(
202  const double _x, const std::string &_node,
203  const bool _loop = true) const;
204 
205 
208  public: void Scale(const double _scale);
209 
212  public: double GetLength() const;
213 
215  protected: std::string name;
216 
218  protected: double length;
219 
221  protected: std::map<std::string, NodeAnimation*> animations;
222  };
224  }
225 }
226 
227 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
double length
the duration of the longest animation
Definition: SkeletonAnimation.hh:218
Skeleton animation.
Definition: SkeletonAnimation.hh:128
std::map< double, ignition::math::Matrix4d > keyFrames
the dictionary of key frames, indexed by time
Definition: SkeletonAnimation.hh:121
std::string name
the node name
Definition: SkeletonAnimation.hh:215
std::map< std::string, NodeAnimation * > animations
a dictionary of node animations
Definition: SkeletonAnimation.hh:221
A key frame in an animation.
Definition: KeyFrame.hh:37
std::string name
the name of the animation
Definition: SkeletonAnimation.hh:118
double length
the duration of the animations (time of last key frame)
Definition: SkeletonAnimation.hh:124
Node animation.
Definition: SkeletonAnimation.hh:41