1 | /*! |
---|
2 | \file simple_animation.h |
---|
3 | \brief A class to interpolate the movement of an object following descrete points in room and time |
---|
4 | \todo implement it |
---|
5 | |
---|
6 | This class has been done to animate some movement, works best for short |
---|
7 | distances. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef _SIMPLE_ANIMATION_H |
---|
11 | #define _SIMPLE_ANIMATION_H |
---|
12 | |
---|
13 | #include "base_object.h" |
---|
14 | #include "p_node.h" |
---|
15 | #include "list.h" |
---|
16 | |
---|
17 | |
---|
18 | typedef enum movementMode{LINEAR=0, EXP, NEG_EXP, SIN, COS, QUADRATIC}; |
---|
19 | |
---|
20 | |
---|
21 | //! KeyFrame Class |
---|
22 | /** |
---|
23 | This represents one point with orientation of the animation |
---|
24 | */ |
---|
25 | class KeyFrame : public PNode { |
---|
26 | public: |
---|
27 | KeyFrame(Vector* point, Quaternion* orientation, float time); |
---|
28 | KeyFrame(Vector* point, Quaternion* orientation, float time, movementMode mode); |
---|
29 | virtual ~KeyFrame(); |
---|
30 | |
---|
31 | void set(Vector* point, Quaternion* orientation, float time); |
---|
32 | void set(Vector* point, Quaternion* orientation, float time, movementMode mode); |
---|
33 | |
---|
34 | float time; |
---|
35 | movementMode mode; |
---|
36 | }; |
---|
37 | |
---|
38 | |
---|
39 | //! Animation Class |
---|
40 | /** |
---|
41 | Helps you making some small animation |
---|
42 | */ |
---|
43 | class SimpleAnimation : public BaseObject { |
---|
44 | |
---|
45 | public: |
---|
46 | SimpleAnimation(PNode* parent); |
---|
47 | virtual ~SimpleAnimation(); |
---|
48 | |
---|
49 | void addKeyFrame(Vector* point, Quaternion* orientation, float time); |
---|
50 | void addKeyFrame(Vector* point, Quaternion* orientation, float time, movementMode mode); |
---|
51 | void addKeyFrame(KeyFrame* frame); |
---|
52 | void reset(); |
---|
53 | |
---|
54 | void start(); |
---|
55 | void stop(); |
---|
56 | void restart(); |
---|
57 | void pause(); |
---|
58 | void resume(); |
---|
59 | |
---|
60 | void tick(float time); |
---|
61 | |
---|
62 | private: |
---|
63 | bool bRunning; //<! is set, when the animation is running |
---|
64 | tList<KeyFrame>* frames; //<! where keyframes are stored in |
---|
65 | KeyFrame* currentFrame; //<! the frame that is been played now |
---|
66 | KeyFrame* lastFrame; |
---|
67 | movementMode mode; //<! this is an enum of the mode, how the speed is distributed |
---|
68 | float localTime; |
---|
69 | PNode* parent; |
---|
70 | |
---|
71 | Vector* tmpVect; //<! this is the temporary vector save place |
---|
72 | |
---|
73 | }; |
---|
74 | |
---|
75 | #endif /* _SIMPLE_ANIMATION_H */ |
---|