/*! \file animation.h A Subclass for all animations in orxonox */ #ifndef _ANIMATION_H #define _ANIMATION_H #include "list.h" #include "base_object.h" // FORWARD DEFINITION #define DELTA_X 0.05 //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta //! An enumerator of Functions to describe the flow of the Animation typedef enum ANIM_FUNCTION {ANIM_CONSTANT, ANIM_LINEAR, ANIM_SINE, ANIM_COSINE, ANIM_EXP, ANIM_NEG_EXP, ANIM_QUADRATIC, ANIM_RANDOM}; //! An enumerator describing what the animation should do after the last keyframe. typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT, ANIM_INF_LINEAR, ANIM_INF_PINGPONG, ANIM_INF_REWIND};//, ANIM_DELETE} //! A Struct for Keyframes that simply hold a float typedef struct KeyFrameF { float duration; //!< duration of this keyframe float value; //!< value of this keyframe ANIM_FUNCTION animFunc; //!< with whitch function to iterate to the next KeyFrameF }; //! A Superclass for describing an animation (all animations will be derived from this one) /** implement in subclasses: * * De-/Constructor * Animation Functions * virtual tick * List of keyFrames * currentKeyFrame/nextKeyFrame * virtual rewind, to go to the first Keyframe. (other functions will call this one) */ class Animation { public: virtual ~Animation(void); void doNotHandle(void); void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT); void play(); // equals resume(); void stop(); void pause(); void replay(); //! A virtual function that should change to the first keyframe. virtual void rewind() = 0; /** \brief A virtual function that ticks the animation \param dt the time passed */ virtual void tick(float dt) = 0; /** \returns the BaseObject, this animation operates on */ BaseObject* getBaseObject(void) const {return baseObject;} protected: Animation(void); // variables float localTime; //!< The Time passed since the beginning of the currentKeyFrame. ANIM_INFINITY postInfinity; //!< describing what the animation should do after the last keyframe. BaseObject* baseObject; //!< The same as object in the derived classes, but with reference to BaseObject bool bHasKeys; //!< If the animation has any keys at all. Needed to add the first keyframe (and delete the dummy). bool bHandled; //!< If this Animation is handled by the AnimationPlayer. bool bRunning; //!< If the animation is running }; /**********************TEST*******************************/ class aTest { public: aTest() { last = 0.0;} ~aTest() {} void littleDebug(float f) { diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;} private: float diff; float last; }; //aTest::aTest() {} //aTest::~aTest() {} //void aTest::littleDebug(float f) /**********************TEST*******************************/ #endif /* _ANIMATION_H */