[4597] | 1 | /*! |
---|
[5039] | 2 | * @file animation3d.h |
---|
[3851] | 3 | */ |
---|
| 4 | |
---|
[3863] | 5 | |
---|
[3851] | 6 | #include "animation.h" |
---|
| 7 | |
---|
| 8 | #include "vector.h" |
---|
[6616] | 9 | #include "quaternion.h" |
---|
[3851] | 10 | class PNode; |
---|
| 11 | |
---|
[4906] | 12 | #define DELTA_X_3D 0.05 //!< the percentag of the distance that doesn't have to be done by neg_exp (asymptotical) ~ maschinendelta |
---|
[3964] | 13 | |
---|
[3851] | 14 | //! KeyFrame3D Struct |
---|
| 15 | /** |
---|
| 16 | This represents one point with direction of the animation |
---|
| 17 | */ |
---|
[10618] | 18 | typedef struct KeyFrame3D |
---|
| 19 | { |
---|
[4485] | 20 | float duration; //!< The duration of this KeyFrame |
---|
| 21 | Vector position; //!< The position of this KeyFrame |
---|
| 22 | Vector lastPosition; //!< The last known position |
---|
| 23 | Quaternion direction; //!< The direction of this KeyFrame |
---|
| 24 | ANIM_FUNCTION animFuncMov; //!< with whitch function to iterate movement to the next KeyFrame3D |
---|
| 25 | ANIM_FUNCTION animFuncRot; //!< with whitch function to iterate rotation to the next KeyFrame3D |
---|
[3851] | 26 | }; |
---|
| 27 | |
---|
[4485] | 28 | //! Animation Class for 3D-transformations (movement and rotation) |
---|
[3851] | 29 | /** |
---|
| 30 | This represents an animation for a object |
---|
| 31 | */ |
---|
| 32 | class Animation3D : public Animation |
---|
| 33 | { |
---|
[10618] | 34 | public: |
---|
[3852] | 35 | Animation3D(PNode* object); |
---|
[4746] | 36 | virtual ~Animation3D(); |
---|
[4597] | 37 | |
---|
[4746] | 38 | virtual void rewind(); |
---|
[3851] | 39 | |
---|
[4906] | 40 | void addKeyFrame(Vector position, Quaternion direction, |
---|
| 41 | float time, ANIM_FUNCTION animFuncMov = ANIM_DEFAULT_FUNCTION, |
---|
| 42 | ANIM_FUNCTION animFuncRot = ANIM_NULL); |
---|
[3855] | 43 | // void addKeyFrame(KeyFrame3D* frame); |
---|
[3851] | 44 | |
---|
[3852] | 45 | virtual void tick(float dt); |
---|
[4597] | 46 | |
---|
[10618] | 47 | private: |
---|
[3851] | 48 | // animation functions |
---|
[3973] | 49 | void setAnimFuncMov(ANIM_FUNCTION animFunc); |
---|
| 50 | void setAnimFuncRot(ANIM_FUNCTION animFunc); |
---|
| 51 | void mConstant(float timePassed) const; |
---|
| 52 | void mLinear(float timePassed) const; |
---|
| 53 | void mSine(float timePassed) const; |
---|
| 54 | void mCosine(float timePassed) const; |
---|
| 55 | void mExp(float timePassed) const; |
---|
| 56 | void mNegExp(float timePassed) const; |
---|
| 57 | void mQuadratic(float timePassed) const; |
---|
| 58 | void mRandom(float timePassed) const; |
---|
| 59 | void rConstant(float timePassed) const; |
---|
| 60 | void rLinear(float timePassed) const; |
---|
| 61 | void rSine(float timePassed) const; |
---|
| 62 | void rCosine(float timePassed) const; |
---|
| 63 | void rExp(float timePassed) const; |
---|
| 64 | void rNegExp(float timePassed) const; |
---|
| 65 | void rQuadratic(float timePassed) const; |
---|
| 66 | void rRandom(float timePassed) const; |
---|
[3851] | 67 | // ANIM_FUNCTION animFunc; |
---|
[3973] | 68 | void (Animation3D::*animFuncMov)(float) const; //!< A Function for the AnimationType |
---|
| 69 | void (Animation3D::*animFuncRot)(float) const; //!< A Function for the AnimationType |
---|
[3851] | 70 | |
---|
[3855] | 71 | |
---|
[10618] | 72 | private: |
---|
| 73 | typedef std::list<KeyFrame3D> KeyFrameList; //!< A Type definition for th KeyFrame List |
---|
| 74 | typedef KeyFrameList::iterator KeyFrameIterator; //!< A Type definition for th KeyFrame List |
---|
[4485] | 75 | |
---|
[10618] | 76 | KeyFrameIterator currentKeyFrame; //!< The current KeyFrame |
---|
| 77 | KeyFrameIterator nextKeyFrame; //!< The KeyFrame we iterate to |
---|
| 78 | KeyFrameList keyFrameList; //!< The KeyFrameList |
---|
[4485] | 79 | |
---|
[10618] | 80 | |
---|
[3851] | 81 | // more class-local description |
---|
[4485] | 82 | PNode* object; //!< The Object from which to Animate something |
---|
| 83 | Vector lastPosition; //!< last Object |
---|
| 84 | Vector tmpVect; //!< temporary vector |
---|
| 85 | float deltaT; //!< time passed since last |
---|
| 86 | float expFactorMov; //!< exponential Factor for movement |
---|
| 87 | float expFactorRot; //!< exponential Factor for rotation |
---|
[3851] | 88 | }; |
---|