All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Animation.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 _ANIMATION_HH_
18 #define _ANIMATION_HH_
19 
20 #include <string>
21 #include <vector>
22 
23 namespace gazebo
24 {
25  namespace math
26  {
27  class Spline;
28  class RotationSpline;
29  }
30 
33 
34  namespace common
35  {
36  class KeyFrame;
37  class PoseKeyFrame;
38  class NumericKeyFrame;
39 
42 
46  class Animation
47  {
52  public: Animation(const std::string &_name, double _length, bool _loop);
53 
55  public: virtual ~Animation();
56 
59  public: double GetLength() const;
60 
63  public: void SetLength(double _len);
64 
67  public: void SetTime(double _time);
68 
71  public: void AddTime(double _time);
72 
75  public: double GetTime() const;
76 
79  public: unsigned int GetKeyFrameCount() const;
80 
84  public: KeyFrame* GetKeyFrame(unsigned int _index) const;
85 
92  protected: double GetKeyFramesAtTime(double _time, KeyFrame **_kf1,
93  KeyFrame **_kf2,
94  unsigned int &_firstKeyIndex) const;
95 
96 
98  protected: std::string name;
99 
101  protected: double length;
102 
104  protected: double timePos;
105 
107  protected: mutable bool build;
108 
110  protected: bool loop;
111 
113  protected: typedef std::vector<KeyFrame*> KeyFrame_V;
114 
116  protected: KeyFrame_V keyFrames;
117  };
119 
122 
124  class PoseAnimation : public Animation
125  {
130  public: PoseAnimation(const std::string &_name,
131  double _length, bool _loop);
132 
134  public: virtual ~PoseAnimation();
135 
139  public: PoseKeyFrame *CreateKeyFrame(double _time);
140 
143  public: void GetInterpolatedKeyFrame(PoseKeyFrame &_kf) const;
144 
148  protected: void GetInterpolatedKeyFrame(double _time,
149  PoseKeyFrame &_kf) const;
150 
152  protected: void BuildInterpolationSplines() const;
153 
155  private: mutable math::Spline *positionSpline;
156 
158  private: mutable math::RotationSpline *rotationSpline;
159  };
161 
164 
167  {
172  public: NumericAnimation(const std::string &_name,
173  double _length, bool _loop);
174 
176  public: virtual ~NumericAnimation();
177 
181  public: NumericKeyFrame *CreateKeyFrame(double _time);
182 
186  public: void GetInterpolatedKeyFrame(NumericKeyFrame &_kf) const;
187  };
189  }
190 }
191 
192 #endif