[3781] | 1 | /*! |
---|
| 2 | \file animation.h |
---|
[3849] | 3 | A Subclass for all animations in orxonox |
---|
[3781] | 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _ANIMATION_H |
---|
| 7 | #define _ANIMATION_H |
---|
| 8 | |
---|
[3795] | 9 | #include "list.h" |
---|
[3833] | 10 | #include "base_object.h" |
---|
| 11 | |
---|
[3782] | 12 | // FORWARD DEFINITION |
---|
| 13 | |
---|
[3832] | 14 | #define DELTA_X 0.05 //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta |
---|
| 15 | |
---|
[3784] | 16 | typedef enum ANIM_FUNCTION {ANIM_CONSTANT, |
---|
| 17 | ANIM_LINEAR, |
---|
| 18 | ANIM_SINE, |
---|
[3825] | 19 | ANIM_COSINE, |
---|
| 20 | ANIM_EXP, |
---|
| 21 | ANIM_NEG_EXP, |
---|
| 22 | ANIM_QUADRATIC, |
---|
[3784] | 23 | ANIM_RANDOM}; |
---|
[3787] | 24 | |
---|
[3784] | 25 | typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT, |
---|
| 26 | ANIM_INF_LINEAR, |
---|
| 27 | ANIM_INF_PINGPONG, |
---|
| 28 | ANIM_INF_REWIND};//, ANIM_DELETE} |
---|
[3543] | 29 | |
---|
[3848] | 30 | typedef struct KeyFrameF |
---|
[3784] | 31 | { |
---|
| 32 | float duration; |
---|
| 33 | float value; |
---|
| 34 | ANIM_FUNCTION animFunc; |
---|
| 35 | }; |
---|
| 36 | |
---|
[3847] | 37 | class Animation |
---|
[3782] | 38 | { |
---|
[3785] | 39 | public: |
---|
[3847] | 40 | virtual ~Animation(void); |
---|
[3820] | 41 | void doNotHandle(void); |
---|
[3794] | 42 | |
---|
| 43 | void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT); |
---|
| 44 | |
---|
| 45 | void play(); // equals resume(); |
---|
| 46 | void stop(); |
---|
| 47 | void pause(); |
---|
| 48 | void replay(); |
---|
[3797] | 49 | virtual void rewind() = 0; |
---|
[3794] | 50 | |
---|
| 51 | virtual void tick(float time) = 0; |
---|
| 52 | |
---|
[3795] | 53 | /* implement in subclasses: |
---|
| 54 | * |
---|
| 55 | * De-/Constructor |
---|
| 56 | * Animation Functions |
---|
| 57 | * virtual tick |
---|
| 58 | * List of keyFrames |
---|
| 59 | * currentKeyFrame/nextKeyFrame |
---|
| 60 | * virtual rewind, to go to the first Keyframe. (other functions will call this one) |
---|
| 61 | */ |
---|
[3833] | 62 | |
---|
| 63 | /** |
---|
| 64 | \returns the BaseObject, this animation operates on |
---|
| 65 | */ |
---|
| 66 | BaseObject* getBaseObject(void) const { return baseObject;} |
---|
| 67 | |
---|
[3782] | 68 | protected: |
---|
[3847] | 69 | Animation(void); |
---|
[3782] | 70 | |
---|
[3784] | 71 | // variables |
---|
[3794] | 72 | |
---|
[3795] | 73 | float localTime; |
---|
[3784] | 74 | ANIM_INFINITY postInfinity; |
---|
| 75 | |
---|
[3833] | 76 | BaseObject* baseObject; //!< The same as object in the derived classes, but with reference to BaseObject |
---|
[3784] | 77 | bool bHasKeys; |
---|
[3820] | 78 | bool bHandled; //!< If this Animation is handled by the AnimationPlayer. |
---|
[3787] | 79 | bool bRunning; |
---|
[3782] | 80 | }; |
---|
| 81 | |
---|
| 82 | |
---|
[3833] | 83 | /**********************TEST*******************************/ |
---|
| 84 | class aTest |
---|
| 85 | { |
---|
| 86 | public: |
---|
| 87 | aTest() { last = 0.0;} |
---|
| 88 | ~aTest() {} |
---|
| 89 | void littleDebug(float f) { diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;} |
---|
| 90 | private: |
---|
| 91 | float diff; |
---|
| 92 | float last; |
---|
| 93 | }; |
---|
| 94 | |
---|
| 95 | //aTest::aTest() {} |
---|
| 96 | //aTest::~aTest() {} |
---|
| 97 | |
---|
| 98 | //void aTest::littleDebug(float f) |
---|
| 99 | |
---|
| 100 | /**********************TEST*******************************/ |
---|
| 101 | |
---|
| 102 | |
---|
[3781] | 103 | #endif /* _ANIMATION_H */ |
---|