1 | /*! |
---|
2 | \file animation.h |
---|
3 | A Subclass for all animations in orxonox |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _ANIMATION_H |
---|
7 | #define _ANIMATION_H |
---|
8 | |
---|
9 | #include "list.h" |
---|
10 | #include "base_object.h" |
---|
11 | |
---|
12 | // FORWARD DEFINITION |
---|
13 | |
---|
14 | #define DELTA_X 0.05 //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta |
---|
15 | |
---|
16 | typedef enum ANIM_FUNCTION {ANIM_CONSTANT, |
---|
17 | ANIM_LINEAR, |
---|
18 | ANIM_SINE, |
---|
19 | ANIM_COSINE, |
---|
20 | ANIM_EXP, |
---|
21 | ANIM_NEG_EXP, |
---|
22 | ANIM_QUADRATIC, |
---|
23 | ANIM_RANDOM}; |
---|
24 | |
---|
25 | typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT, |
---|
26 | ANIM_INF_LINEAR, |
---|
27 | ANIM_INF_PINGPONG, |
---|
28 | ANIM_INF_REWIND};//, ANIM_DELETE} |
---|
29 | |
---|
30 | typedef struct KeyFrameF |
---|
31 | { |
---|
32 | float duration; |
---|
33 | float value; |
---|
34 | ANIM_FUNCTION animFunc; |
---|
35 | }; |
---|
36 | |
---|
37 | class Animation |
---|
38 | { |
---|
39 | public: |
---|
40 | virtual ~Animation(void); |
---|
41 | void doNotHandle(void); |
---|
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(); |
---|
49 | virtual void rewind() = 0; |
---|
50 | |
---|
51 | virtual void tick(float dt) = 0; |
---|
52 | |
---|
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 | */ |
---|
62 | |
---|
63 | /** |
---|
64 | \returns the BaseObject, this animation operates on |
---|
65 | */ |
---|
66 | BaseObject* getBaseObject(void) const {return baseObject;} |
---|
67 | |
---|
68 | protected: |
---|
69 | Animation(void); |
---|
70 | |
---|
71 | // variables |
---|
72 | |
---|
73 | float localTime; |
---|
74 | ANIM_INFINITY postInfinity; |
---|
75 | |
---|
76 | BaseObject* baseObject; //!< The same as object in the derived classes, but with reference to BaseObject |
---|
77 | bool bHasKeys; |
---|
78 | bool bHandled; //!< If this Animation is handled by the AnimationPlayer. |
---|
79 | bool bRunning; |
---|
80 | }; |
---|
81 | |
---|
82 | |
---|
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 | |
---|
103 | #endif /* _ANIMATION_H */ |
---|