]> git.tdb.fi Git - libs/gl.git/blobdiff - source/animation.h
Restructure Animation to make matrix interpolation code more reusable
[libs/gl.git] / source / animation.h
index 1460c944894350ed5aa44ea57f5c0465c8da6a44..a4bdabdd95401757b32c032ca56b646c2e58c92b 100644 (file)
@@ -41,15 +41,32 @@ private:
                float scale;
 
                AxisInterpolation();
+               AxisInterpolation(const double *, const double *);
+       };
+
+       struct MatrixInterpolation
+       {
+               const Matrix *matrix1;
+               const Matrix *matrix2;
+               AxisInterpolation axes[3];
+
+               MatrixInterpolation();
+               MatrixInterpolation(const Matrix &, const Matrix &);
+
+               Matrix get(float) const;
        };
 
        struct TimedKeyFrame
        {
+               const Animation &animation;
                const TimedKeyFrame *prev;
                Time::TimeDelta time;
                Time::TimeDelta delta_t;
                RefPtr<const KeyFrame> keyframe;
-               AxisInterpolation axes[3];
+               MatrixInterpolation matrix;
+
+               TimedKeyFrame(const Animation &);
+               void prepare();
        };
 
        typedef std::list<TimedKeyFrame> KeyFrameList;
@@ -80,11 +97,11 @@ public:
        Animation();
 
        void add_keyframe(const Time::TimeDelta &, const KeyFrame &);
-       void set_looping(bool);
 private:
        void prepare_keyframe(TimedKeyFrame &);
 
-       Matrix compute_matrix(const TimedKeyFrame &, const Time::TimeDelta &) const;
+public:
+       void set_looping(bool);
 };
 
 } // namespace GL