X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fanimation.h;h=616d0e74e9ab8beadc2c39b4010786d2f57082cb;hp=011c8558ca52f32659247c263b7cdb17f46359c5;hb=553f3ec4fbe28a37978ee53b9b6e22fedb691e1d;hpb=8bc776f177c7cf9d0c6fd9590273f086d38c23ca diff --git a/source/animation.h b/source/animation.h index 011c8558..616d0e74 100644 --- a/source/animation.h +++ b/source/animation.h @@ -69,8 +69,9 @@ private: { protected: CurveTarget target; + int component; - Curve(CurveTarget); + Curve(CurveTarget, int); public: virtual ~Curve() { } @@ -88,12 +89,25 @@ private: 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 { @@ -154,6 +168,7 @@ private: bool looping; std::vector uniforms; std::vector curves; + unsigned uniform_curve_offset; public: Animation(); @@ -175,8 +190,9 @@ private: 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 &);