All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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
double length
animation duration
Definition: Animation.hh:102
A numeric animation.
Definition: Animation.hh:167
bool loop
true if animation repeats
Definition: Animation.hh:111
A keyframe for a NumericAnimation.
Definition: KeyFrame.hh:84
std::string name
animation name
Definition: Animation.hh:99
double timePos
current time position
Definition: Animation.hh:105
Manages an animation, which is a collection of keyframes and the ability to interpolate between the k...
Definition: Animation.hh:47
Splines.
Definition: Spline.hh:37
std::vector< KeyFrame * > KeyFrame_V
array of keyframe type alias
Definition: Animation.hh:114
A keyframe for a PoseAnimation.
Definition: KeyFrame.hh:51
Spline for rotations.
Definition: RotationSpline.hh:33
A key frame in an animation.
Definition: KeyFrame.hh:33
A pose animation.
Definition: Animation.hh:125
bool build
determines if the interpolation splines need building
Definition: Animation.hh:108
KeyFrame_V keyFrames
array of key frames
Definition: Animation.hh:117
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48