1 #ifndef MSP_GL_ANIMATION_H_
2 #define MSP_GL_ANIMATION_H_
4 #include <msp/core/refptr.h>
5 #include <msp/datafile/objectloader.h>
6 #include <msp/time/timedelta.h>
15 An Animation is a sequence of KeyFrames combined with timing information. The
16 state at any point in the animation can be interpolated from the keyframes.
21 class Loader: public DataFile::CollectionObjectLoader<Animation>
24 Time::TimeDelta current_time;
28 Loader(Animation &, Collection &);
32 void keyframe(const std::string &);
33 void keyframe_inline();
38 struct AxisInterpolation
44 AxisInterpolation(const double *, const double *);
47 struct MatrixInterpolation
49 const Matrix *matrix1;
50 const Matrix *matrix2;
51 AxisInterpolation axes[3];
53 MatrixInterpolation();
54 MatrixInterpolation(const Matrix &, const Matrix &);
56 Matrix get(float) const;
61 const Animation &animation;
62 const TimedKeyFrame *prev;
64 Time::TimeDelta delta_t;
65 RefPtr<const KeyFrame> keyframe;
66 MatrixInterpolation matrix;
68 TimedKeyFrame(const Animation &);
72 typedef std::list<TimedKeyFrame> KeyFrameList;
78 const Animation &animation;
79 KeyFrameList::const_iterator iter;
80 Time::TimeDelta time_since_keyframe;
84 Iterator(const Animation &);
86 Iterator &operator+=(const Time::TimeDelta &);
88 bool is_end() const { return end; }
89 Matrix get_matrix() const;
93 KeyFrameList keyframes;
99 void add_keyframe(const Time::TimeDelta &, const KeyFrame &);
101 void prepare_keyframe(TimedKeyFrame &);
104 void set_looping(bool);