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 #include "gazebo/util/system.hh"
23 
24 namespace gazebo
25 {
26  namespace math
27  {
28  class Spline;
29  class RotationSpline;
30  }
31 
34 
35  namespace common
36  {
37  class KeyFrame;
38  class PoseKeyFrame;
39  class NumericKeyFrame;
40 
43 
48  {
53  public: Animation(const std::string &_name, double _length, bool _loop);
54 
56  public: virtual ~Animation();
57 
60  public: double GetLength() const;
61 
64  public: void SetLength(double _len);
65 
68  public: void SetTime(double _time);
69 
72  public: void AddTime(double _time);
73 
76  public: double GetTime() const;
77 
80  public: unsigned int GetKeyFrameCount() const;
81 
85  public: KeyFrame* GetKeyFrame(unsigned int _index) const;
86 
93  protected: double GetKeyFramesAtTime(double _time, KeyFrame **_kf1,
94  KeyFrame **_kf2,
95  unsigned int &_firstKeyIndex) const;
96 
97 
99  protected: std::string name;
100 
102  protected: double length;
103 
105  protected: double timePos;
106 
108  protected: mutable bool build;
109 
111  protected: bool loop;
112 
114  protected: typedef std::vector<KeyFrame*> KeyFrame_V;
115 
117  protected: KeyFrame_V keyFrames;
118  };
120 
123 
126  {
131  public: PoseAnimation(const std::string &_name,
132  double _length, bool _loop);
133 
135  public: virtual ~PoseAnimation();
136 
140  public: PoseKeyFrame *CreateKeyFrame(double _time);
141 
144  public: void GetInterpolatedKeyFrame(PoseKeyFrame &_kf) const;
145 
149  protected: void GetInterpolatedKeyFrame(double _time,
150  PoseKeyFrame &_kf) const;
151 
153  protected: void BuildInterpolationSplines() const;
154 
156  private: mutable math::Spline *positionSpline;
157 
159  private: mutable math::RotationSpline *rotationSpline;
160  };
162 
165 
168  {
173  public: NumericAnimation(const std::string &_name,
174  double _length, bool _loop);
175 
177  public: virtual ~NumericAnimation();
178 
182  public: NumericKeyFrame *CreateKeyFrame(double _time);
183 
187  public: void GetInterpolatedKeyFrame(NumericKeyFrame &_kf) const;
188  };
190  }
191 }
192 
193 #endif