/*! \file animation.h A Subclass for all animations in orxonox */ #ifndef _ANIMATION_H #define _ANIMATION_H #include "list.h" #include "base_object.h" #include "confincl.h" // must be here to determin the DEBUG-level // FORWARD DEFINITION //! An enumerator of Functions to describe the flow of the Animation /** \todo check with Patrick it of description in speed to the next keyframe: ANIM_CONSTANT: 0, infinity. ANIM_LINEAR: equal ANIM_SINE: fast, slow, fast ANIM_COSINE: slow, fast, slow ANIM_EXP: slow, fast ANIM_NEG_EXP: fast, slow ANIM_RANDOM: eratic deprecated QUADRATIC */ 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. /** ANIM_INF_CONSTANT stays at the end of the animation ANIM_INF_REPLAY loops back to the beginning and replays the animation ANIM_INF_REWIND loops back to the beginning and then stops the animation ANIM_INF_DELETE deletes the animation. !! THIS IS DANGEROUS !! only do this with non-class variables */ typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT, ANIM_INF_REPLAY, ANIM_INF_REWIND, ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG; //! A Superclass for describing an animation (all animations will be derived from this one) /** implement in subclasses: * * De-/Constructor * Animation Functions * virtual tick * addKeyFrame * 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;} /** \returns if the Animation should be deleted */ inline bool ifDelete(void) {return bDelete;} protected: Animation(void); void handleInfinity(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 unsigned int keyFrameCount; //!< The Count of KeyFrames. bool bHandled; //!< If this Animation is handled by the AnimationPlayer. bool bRunning; //!< If the animation is running bool bDelete; //!< If true, the animation will be deleted through the AnimationPlayer. }; /**********************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 */