Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/animation.h @ 3856

Last change on this file since 3856 was 3853, checked in by bensch, 20 years ago

orxonox/trunk: doxygen-comments

File size: 3.0 KB
Line 
1/*!
2    \file animation.h
3    A Subclass for all animations in orxonox
4*/
5
6#ifndef _ANIMATION_H
7#define _ANIMATION_H
8
9#include "list.h"
10#include "base_object.h"
11
12// FORWARD DEFINITION
13
14#define DELTA_X 0.05  //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta
15
16//! An enumerator of Functions to describe the flow of the Animation
17typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
18                            ANIM_LINEAR,
19                            ANIM_SINE,
20                            ANIM_COSINE,
21                            ANIM_EXP,
22                            ANIM_NEG_EXP,
23                            ANIM_QUADRATIC,
24                            ANIM_RANDOM};
25
26//! An enumerator describing what the animation should do after the last keyframe.
27typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT,
28                            ANIM_INF_LINEAR,
29                            ANIM_INF_PINGPONG,
30                            ANIM_INF_REWIND};//, ANIM_DELETE}
31
32//! A Struct for Keyframes that simply hold a float
33typedef struct KeyFrameF
34{
35  float duration;             //!< duration of this keyframe
36  float value;                //!< value of this keyframe
37  ANIM_FUNCTION animFunc;     //!< with whitch function to iterate to the next KeyFrameF
38};
39
40//! A Superclass for describing an animation (all animations will be derived from this one)
41/** implement in subclasses:
42 *
43 * De-/Constructor
44 * Animation Functions
45 * virtual tick
46 * List of keyFrames
47 * currentKeyFrame/nextKeyFrame
48 * virtual rewind, to go to the first Keyframe. (other functions will call this one)
49*/
50class Animation
51{
52 public:
53  virtual ~Animation(void);
54  void doNotHandle(void);
55
56  void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
57
58  void play(); // equals resume();
59  void stop();
60  void pause();
61  void replay();
62  //! A virtual function that should change to the first keyframe.
63  virtual void rewind() = 0;
64  /** \brief A virtual function that ticks the animation \param dt the time passed */
65  virtual void tick(float dt) = 0;
66
67  /**
68     \returns the BaseObject, this animation operates on
69  */
70  BaseObject* getBaseObject(void) const {return baseObject;}
71
72 protected:
73  Animation(void);
74
75  // variables
76  float localTime;                //!< The Time passed since the beginning of the currentKeyFrame.
77  ANIM_INFINITY postInfinity;     //!< describing what the animation should do after the last keyframe.
78
79  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
80  bool bHasKeys;                  //!< If the animation has any keys at all. Needed to add the first keyframe (and delete the dummy).
81  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
82  bool bRunning;                  //!< If the animation is running
83};
84
85
86/**********************TEST*******************************/
87class aTest
88{
89 public:
90  aTest() { last = 0.0;}
91  ~aTest() {}
92  void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
93 private:
94  float diff;
95  float last;
96};
97
98//aTest::aTest() {}
99//aTest::~aTest() {}
100
101//void aTest::littleDebug(float f)
102
103/**********************TEST*******************************/
104
105
106#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.