Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/animation/animation3d.h @ 10630

Last change on this file since 10630 was 10618, checked in by bknecht, 18 years ago

merged cleanup into trunk (only improvements)

File size: 3.3 KB
Line 
1/*!
2 * @file animation3d.h
3*/
4
5
6#include "animation.h"
7
8#include "vector.h"
9#include "quaternion.h"
10class PNode;
11
12#define DELTA_X_3D 0.05  //!< the percentag of the distance that doesn't have to be done by neg_exp (asymptotical) ~ maschinendelta
13
14//! KeyFrame3D Struct
15/**
16   This represents one point with direction of the animation
17*/
18typedef struct KeyFrame3D
19{
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
26};
27
28//! Animation Class for 3D-transformations (movement and rotation)
29/**
30   This represents an animation for a object
31*/
32class Animation3D : public Animation
33{
34public:
35  Animation3D(PNode* object);
36  virtual ~Animation3D();
37
38  virtual void rewind();
39
40  void addKeyFrame(Vector position, Quaternion direction,
41                   float time, ANIM_FUNCTION animFuncMov = ANIM_DEFAULT_FUNCTION,
42                   ANIM_FUNCTION animFuncRot = ANIM_NULL);
43  //  void addKeyFrame(KeyFrame3D* frame);
44
45  virtual void tick(float dt);
46
47private:
48  // animation functions
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;
67  //  ANIM_FUNCTION animFunc;
68  void (Animation3D::*animFuncMov)(float) const;      //!< A Function for the AnimationType
69  void (Animation3D::*animFuncRot)(float) const;      //!< A Function for the AnimationType
70
71
72private:
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
75
76  KeyFrameIterator     currentKeyFrame;               //!< The current KeyFrame
77  KeyFrameIterator     nextKeyFrame;                  //!< The KeyFrame we iterate to
78  KeyFrameList         keyFrameList;                  //!< The KeyFrameList
79
80
81  // more class-local description
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
88};
Note: See TracBrowser for help on using the repository browser.