X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fanimation.h;h=83b369bfca1f1e975df889de113d9655ca77db80;hp=b9e9fe1f3d1bd25e7a10efd3c0d7648eadd75000;hb=025016d7628be9c43b20999325dcbaae5cb3c3b8;hpb=a9c375e17065bcc429b430bd8211a9ee845159a5 diff --git a/source/animation.h b/source/animation.h index b9e9fe1f..83b369bf 100644 --- a/source/animation.h +++ b/source/animation.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "keyframe.h" @@ -33,6 +34,7 @@ public: Loader(Animation &, Collection &); private: void init(); + virtual void finish(); void event(const std::string &); void event1i(const std::string &, int); @@ -47,41 +49,49 @@ public: }; private: - struct AxisInterpolation + enum CurveTarget { - float slope; - float scale; + POSITION, + EULER, + SCALE, + UNIFORM + }; + + class Curve + { + protected: + CurveTarget target; + + Curve(CurveTarget); + public: + virtual ~Curve() { } - AxisInterpolation(); - AxisInterpolation(const float *, const float *); + virtual void apply(float, Matrix &) const = 0; + virtual void apply(float, KeyFrame::AnimatedUniform &) const = 0; }; - struct MatrixInterpolation + template + class ValueCurve: public Curve { - const Matrix *matrix1; - const Matrix *matrix2; - AxisInterpolation axes[3]; + public: + typedef typename Interpolate::SplineKnot Knot; - MatrixInterpolation(); - MatrixInterpolation(const Matrix &, const Matrix &); + private: + Interpolate::Spline spline; - Matrix get(float) const; + public: + ValueCurve(CurveTarget, const std::vector &); + + virtual void apply(float, Matrix &) const; + virtual void apply(float, KeyFrame::AnimatedUniform &) const; }; struct TimedKeyFrame { - const TimedKeyFrame *prev; Time::TimeDelta time; - Time::TimeDelta delta_t; float start_slope; float end_slope; RefPtr keyframe; - MatrixInterpolation matrix; - std::vector uniforms; - std::vector pose_matrices; - - TimedKeyFrame(); - void prepare(const Animation &); }; struct Event @@ -104,10 +114,8 @@ public: { private: const Animation *animation; - std::vector::const_iterator iter; + Time::TimeDelta elapsed; std::vector::const_iterator event_iter; - Time::TimeDelta time_since_keyframe; - float x; bool end; public: @@ -128,6 +136,7 @@ private: std::vector events; bool looping; std::vector uniforms; + std::vector curves; public: Animation(); @@ -146,6 +155,9 @@ public: private: void add_keyframe(const Time::TimeDelta &, const RefPtr &, float, float); void prepare_keyframe(TimedKeyFrame &); + void create_curves(); + template + void create_uniform_curve(const std::string &); public: void add_event(const Time::TimeDelta &, const std::string &, const Variant & = Variant());