/*! \file simple_animation.h \brief A class to interpolate the movement of an object following descrete points in room and time \todo implement it This class has been done to animate some movement, works best for short distances. */ #ifndef _SIMPLE_ANIMATION_H #define _SIMPLE_ANIMATION_H #include "base_object.h" #include "list.h" #include "animation.h" class Vector; class Quaternion; class PNode; typedef enum movementMode{LINEAR=0, EXP, NEG_EXP, SIN, COS, QUADRATIC}; typedef enum animationMode{SINGLE=0, LOOP}; #define DEFAULT_ANIMATION_MODE LINEAR //! KeyFrame Struct /** This represents one point with direction of the animation */ typedef struct KeyFrame3D { Vector* position; Quaternion* direction; PNode* object; float time; movementMode mode; }; //! Animation Struct /** This represents an animation for a object */ class Animation3D : public Animation { public: Animation3D(void); virtual ~Animation3D(void); virtual void rewind(void); void addKeyFrame(Vector* point, Quaternion* direction, float time, ANIM_FUNCTION animFunc = ANIM_LINEAR); void addKeyFrame(KeyFrame3D* frame); virtual void tick(float timePassed); // animation functions void setAnimFunc(ANIM_FUNCTION animFunc); private: float constant(float timePassed) const; float linear(float timePassed) const; float sine(float timePassed) const; float cosine(float timePassed) const; float exp(float timePassed) const; float negExp(float timePassed) const; float quadratic(float timePassed) const; float random(float timePassed) const; // ANIM_FUNCTION animFunc; KeyFrame3D* currentKeyFrame; KeyFrame3D* nextKeyFrame; tList* keyFrameList; float (Animation3D::*animFunc)(float) const; // private PNode* object; Vector* lastPosition; Vector* tmpVect; float deltaT; float localTime; tList* frames; KeyFrame3D* currentFrame; KeyFrame3D* lastFrame; bool bRunning; animationMode animMode; movementMode movMode; }; //! Animation Class /** Helps you making some small animation */ class SimpleAnimation : public BaseObject { public: static SimpleAnimation* getInstance(); virtual ~SimpleAnimation(); void animatorBegin(); void animatorEnd(); void selectObject(PNode* entity); void addKeyFrame(Vector* point, Quaternion* direction, float time); void addKeyFrame(Vector* point, Quaternion* direction, float time, movementMode mode); void addKeyFrame(KeyFrame3D* frame); void setAnimationMode(animationMode mode); void reset(); void start(); void stop(); void restart(); void pause(); void resume(); void tick(float time); private: SimpleAnimation(); static SimpleAnimation* singletonRef; bool bDescriptive; //* frames; //* animators; //