| [3573] | 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 "list.h" |
|---|
| 15 | |
|---|
| 16 | |
|---|
| [3726] | 17 | class Vector; |
|---|
| 18 | class Quaternion; |
|---|
| 19 | class WorldEntity; |
|---|
| 20 | class PNode; |
|---|
| 21 | |
|---|
| [3717] | 22 | typedef enum movementMode{LINEAR=0, EXP, NEG_EXP, SIN, COS, QUADRATIC}; |
|---|
| [3726] | 23 | #define DEFAULT_ANIMATION_MODE LINEAR |
|---|
| [3573] | 24 | |
|---|
| [3726] | 25 | //! KeyFrame Struct |
|---|
| [3573] | 26 | /** |
|---|
| [3729] | 27 | This represents one point with direction of the animation |
|---|
| [3573] | 28 | */ |
|---|
| [3726] | 29 | typedef struct KeyFrame { |
|---|
| 30 | Vector* position; |
|---|
| [3729] | 31 | Quaternion* direction; |
|---|
| [3726] | 32 | WorldEntity* object; |
|---|
| [3573] | 33 | float time; |
|---|
| 34 | movementMode mode; |
|---|
| 35 | }; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | //! Animation Class |
|---|
| 39 | /** |
|---|
| 40 | Helps you making some small animation |
|---|
| 41 | */ |
|---|
| 42 | class SimpleAnimation : public BaseObject { |
|---|
| 43 | |
|---|
| 44 | public: |
|---|
| [3727] | 45 | static SimpleAnimation* getInstance(); |
|---|
| [3573] | 46 | |
|---|
| [3729] | 47 | void animatorBegin(); |
|---|
| 48 | void animatorEnd(); |
|---|
| [3727] | 49 | void selectObject(WorldEntity* entity); |
|---|
| [3729] | 50 | void addKeyFrame(Vector* point, Quaternion* direction, float time); |
|---|
| 51 | void addKeyFrame(Vector* point, Quaternion* direction, float time, movementMode mode); |
|---|
| [3573] | 52 | void addKeyFrame(KeyFrame* frame); |
|---|
| 53 | void reset(); |
|---|
| 54 | |
|---|
| [3727] | 55 | |
|---|
| [3573] | 56 | void start(); |
|---|
| 57 | void stop(); |
|---|
| 58 | void restart(); |
|---|
| 59 | void pause(); |
|---|
| 60 | void resume(); |
|---|
| 61 | |
|---|
| 62 | void tick(float time); |
|---|
| 63 | |
|---|
| 64 | private: |
|---|
| [3727] | 65 | SimpleAnimation(); |
|---|
| 66 | virtual ~SimpleAnimation(); |
|---|
| 67 | |
|---|
| 68 | static SimpleAnimation* singletonRef; |
|---|
| [3733] | 69 | bool bDescriptive; //<! is true, when AnimatorBegin() was executed but no AnimatorEnd() yet: in describtive mode: pass commands |
|---|
| [3719] | 70 | bool bRunning; //<! is set, when the animation is running |
|---|
| [3717] | 71 | tList<KeyFrame>* frames; //<! where keyframes are stored in |
|---|
| 72 | KeyFrame* currentFrame; //<! the frame that is been played now |
|---|
| [3719] | 73 | KeyFrame* lastFrame; |
|---|
| [3729] | 74 | Vector* lastPosition; |
|---|
| [3717] | 75 | movementMode mode; //<! this is an enum of the mode, how the speed is distributed |
|---|
| [3573] | 76 | float localTime; |
|---|
| 77 | PNode* parent; |
|---|
| 78 | |
|---|
| [3726] | 79 | Vector* tmpVect; //<! this is the temporary vector save place - |
|---|
| [3727] | 80 | WorldEntity* workingObject; //<! this is a pointer to the current working object that has been selected via selectObject() |
|---|
| [3733] | 81 | float deltaT; //<! this is a time constant for the movement |
|---|
| 82 | |
|---|
| [3573] | 83 | }; |
|---|
| 84 | |
|---|
| 85 | #endif /* _SIMPLE_ANIMATION_H */ |
|---|