| [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 | */ | 
|---|
 | 18 | typedef struct KeyFrame3D { | 
|---|
| [4485] | 19 |   float             duration;              //!< The duration of this KeyFrame | 
|---|
 | 20 |   Vector            position;              //!< The position of this KeyFrame | 
|---|
 | 21 |   Vector            lastPosition;          //!< The last known position | 
|---|
 | 22 |   Quaternion        direction;             //!< The direction of this KeyFrame | 
|---|
 | 23 |   ANIM_FUNCTION     animFuncMov;           //!< with whitch function to iterate movement to the next KeyFrame3D | 
|---|
 | 24 |   ANIM_FUNCTION     animFuncRot;           //!< with whitch function to iterate rotation to the next KeyFrame3D | 
|---|
| [3851] | 25 | }; | 
|---|
 | 26 |  | 
|---|
| [4485] | 27 | //! Animation Class for 3D-transformations (movement and rotation) | 
|---|
| [3851] | 28 | /** | 
|---|
 | 29 |    This represents an animation for a object | 
|---|
 | 30 | */ | 
|---|
 | 31 | class Animation3D : public Animation | 
|---|
 | 32 | { | 
|---|
 | 33 |  public: | 
|---|
| [3852] | 34 |   Animation3D(PNode* object); | 
|---|
| [4746] | 35 |   virtual ~Animation3D(); | 
|---|
| [4597] | 36 |  | 
|---|
| [4746] | 37 |   virtual void rewind(); | 
|---|
| [3851] | 38 |  | 
|---|
| [4906] | 39 |   void addKeyFrame(Vector position, Quaternion direction, | 
|---|
 | 40 |                    float time, ANIM_FUNCTION animFuncMov = ANIM_DEFAULT_FUNCTION, | 
|---|
 | 41 |                    ANIM_FUNCTION animFuncRot = ANIM_NULL); | 
|---|
| [3855] | 42 |   //  void addKeyFrame(KeyFrame3D* frame); | 
|---|
| [3851] | 43 |  | 
|---|
| [3852] | 44 |   virtual void tick(float dt); | 
|---|
| [4597] | 45 |  | 
|---|
| [3859] | 46 |  private: | 
|---|
| [3851] | 47 |   // animation functions | 
|---|
| [3973] | 48 |   void setAnimFuncMov(ANIM_FUNCTION animFunc); | 
|---|
 | 49 |   void setAnimFuncRot(ANIM_FUNCTION animFunc); | 
|---|
 | 50 |   void mConstant(float timePassed) const; | 
|---|
 | 51 |   void mLinear(float timePassed) const; | 
|---|
 | 52 |   void mSine(float timePassed) const; | 
|---|
 | 53 |   void mCosine(float timePassed) const; | 
|---|
 | 54 |   void mExp(float timePassed) const; | 
|---|
 | 55 |   void mNegExp(float timePassed) const; | 
|---|
 | 56 |   void mQuadratic(float timePassed) const; | 
|---|
 | 57 |   void mRandom(float timePassed) const; | 
|---|
 | 58 |   void rConstant(float timePassed) const; | 
|---|
 | 59 |   void rLinear(float timePassed) const; | 
|---|
 | 60 |   void rSine(float timePassed) const; | 
|---|
 | 61 |   void rCosine(float timePassed) const; | 
|---|
 | 62 |   void rExp(float timePassed) const; | 
|---|
 | 63 |   void rNegExp(float timePassed) const; | 
|---|
 | 64 |   void rQuadratic(float timePassed) const; | 
|---|
 | 65 |   void rRandom(float timePassed) const; | 
|---|
| [3851] | 66 |   //  ANIM_FUNCTION animFunc; | 
|---|
| [3973] | 67 |   void (Animation3D::*animFuncMov)(float) const;      //!< A Function for the AnimationType | 
|---|
 | 68 |   void (Animation3D::*animFuncRot)(float) const;      //!< A Function for the AnimationType | 
|---|
| [3851] | 69 |  | 
|---|
| [3855] | 70 |  | 
|---|
| [4485] | 71 |  private: | 
|---|
 | 72 |   KeyFrame3D*          currentKeyFrame;               //!< The current KeyFrame | 
|---|
 | 73 |   KeyFrame3D*          nextKeyFrame;                  //!< The KeyFrame we iterate to | 
|---|
 | 74 |   tList<KeyFrame3D>*   keyFrameList;                  //!< The KeyFrameList | 
|---|
 | 75 |  | 
|---|
 | 76 |  | 
|---|
| [3851] | 77 |   // more class-local description | 
|---|
| [4485] | 78 |   PNode*               object;                        //!< The Object from which to Animate something | 
|---|
 | 79 |   Vector               lastPosition;                  //!< last Object | 
|---|
 | 80 |   Vector               tmpVect;                       //!< temporary vector | 
|---|
 | 81 |   float                deltaT;                        //!< time passed since last | 
|---|
 | 82 |   float                expFactorMov;                  //!< exponential Factor for movement | 
|---|
 | 83 |   float                expFactorRot;                  //!< exponential Factor for rotation | 
|---|
| [3851] | 84 | }; | 
|---|