X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fanimation.h;h=6845d23ee3e1652c9f7e49a86e5145f3faa6aa52;hp=7b86eca9b162a56cd38e29ae1c17f05a326bce3b;hb=bec07999d95b76f4b47cffcc564d0cd0afc0435e;hpb=29ee3d841a610d24ccfa3e16e492e278f81f64bd diff --git a/source/animation.h b/source/animation.h index 7b86eca9..6845d23e 100644 --- a/source/animation.h +++ b/source/animation.h @@ -28,6 +28,7 @@ public: Time::TimeDelta current_time; float start_slope; float end_slope; + int slopes_set; public: Loader(Animation &); @@ -36,6 +37,8 @@ public: void init(); virtual void finish(); + void check_slopes_and_control(bool, bool); + void add_kf(const KeyFrame *, bool, bool); void load_kf(const std::string &, bool); void load_kf_inline(bool); @@ -66,8 +69,9 @@ private: { protected: CurveTarget target; + int component; - Curve(CurveTarget); + Curve(CurveTarget, int); public: virtual ~Curve() { } @@ -79,18 +83,31 @@ private: class ValueCurve: public Curve { public: - typedef typename Interpolate::SplineKnot Knot; + typedef typename Interpolate::SplineKnot Knot; private: - Interpolate::Spline spline; + Interpolate::Spline spline; public: - ValueCurve(CurveTarget, const std::vector &); + ValueCurve(CurveTarget, int, const std::vector &); virtual void apply(float, Matrix &) const; virtual void apply(float, KeyFrame::AnimatedUniform &) const; }; + struct ExtractComponent + { + typedef bool (*Extract)(const KeyFrame &, Vector3 &); + + Extract extract; + unsigned index; + Transform::ComponentMask mask; + + ExtractComponent(Extract e, unsigned i, Transform::ComponentMask m): extract(e), index(i), mask(m) { } + + bool operator()(const KeyFrame &, float &) const; + }; + template struct ExtractUniform { @@ -151,6 +168,7 @@ private: bool looping; std::vector uniforms; std::vector curves; + unsigned uniform_curve_offset; public: Animation(); @@ -164,15 +182,19 @@ public: const std::string &get_uniform_name(unsigned) const; void add_keyframe(const Time::TimeDelta &, const KeyFrame &); - void add_keyframe(const Time::TimeDelta &, const KeyFrame &, float); - void add_keyframe(const Time::TimeDelta &, const KeyFrame &, float, float); + void add_keyframe_owned(const Time::TimeDelta &, const KeyFrame *); + DEPRECATED void add_keyframe(const Time::TimeDelta &, const KeyFrame &, float); + DEPRECATED void add_keyframe(const Time::TimeDelta &, const KeyFrame &, float, float); void add_control_keyframe(const KeyFrame &); + void add_control_keyframe_owned(const KeyFrame *); private: + void add_keyframe(const Time::TimeDelta &, const KeyFrame *, float, float, bool); void add_keyframe(const Time::TimeDelta &, const KeyFrame *, bool, bool); void prepare_keyframe(TimedKeyFrame &); void create_curves(); + void create_curve(CurveTarget, Transform::ComponentMask, ExtractComponent::Extract); template - void create_curve(CurveTarget target, const T &); + void create_curve(CurveTarget target, int, const T &); static bool extract_position(const KeyFrame &, Vector3 &); static bool extract_euler(const KeyFrame &, Vector3 &); static bool extract_scale(const KeyFrame &, Vector3 &); @@ -182,6 +204,7 @@ public: const Msp::Time::TimeDelta &get_duration() const; void set_looping(bool); + bool is_looping() const { return looping; } }; } // namespace GL