Animation.hh
00001 #ifndef ANIMATION_HH
00002 #define ANIMATION_HH
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 namespace gazebo
00008 {
00009   namespace math
00010   {
00011     class Spline;
00012     class RotationSpline;
00013   }
00014 
00015   namespace common
00016   {
00017     class KeyFrame;
00018     class PoseKeyFrame;
00019     class NumericKeyFrame;
00020 
00021     class Animation
00022     {
00023       public: Animation(const std::string _name, double _length, bool _loop);
00024       public: virtual ~Animation();
00025 
00026       public: double GetLength() const;
00027       public: void SetLength(double _len);
00028 
00029       public: void SetTime(double _time);
00030       public: void AddTime(double _time);
00031       public: double GetTime() const;
00032 
00033       protected: double GetKeyFramesAtTime(double _time, KeyFrame **_kf1,
00034                                            KeyFrame **_kf2, 
00035                                            unsigned int &_firstKeyIndex) const;
00036 
00037 
00038       protected: std::string name;
00039       protected: double length;
00040       protected: double timePos;
00041       protected: mutable bool build;
00042       protected: bool loop;
00043 
00044       protected: typedef std::vector<KeyFrame*> KeyFrame_V;
00045       protected: KeyFrame_V keyFrames;
00046     };
00047 
00048     class PoseAnimation : public Animation
00049     {
00050       public: PoseAnimation(const std::string _name, 
00051                             double _length, bool _loop);
00052       public: virtual ~PoseAnimation();
00053 
00054       public: PoseKeyFrame *CreateKeyFrame(double _time);
00055 
00056       public: void GetInterpolatedKeyFrame(PoseKeyFrame &_kf) const;
00057 
00058       protected: void GetInterpolatedKeyFrame(double _time, 
00059                                               PoseKeyFrame &_kf) const;
00060 
00061       protected: void BuildInterpolationSplines() const;
00062 
00063       private: mutable math::Spline *positionSpline;
00064       private: mutable math::RotationSpline *rotationSpline;
00065     };
00066 
00067     class NumericAnimation : public Animation
00068     {
00069       public: NumericAnimation(const std::string _name, 
00070                                double _length, bool _loop);
00071       public: virtual ~NumericAnimation();
00072 
00073       public: NumericKeyFrame *CreateKeyFrame(double _time);
00074 
00075       public: void GetInterpolatedKeyFrame(NumericKeyFrame &_kf) const;
00076     };
00077   }
00078 }
00079 
00080 #endif