Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4463 was 4381, checked in by bensch, 20 years ago

orxonox/trunk: made include more local. stdincl.h not in base_object.h anymore

File size: 3.8 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#include "confincl.h"  // must be here to determin the DEBUG-level
12#include "debug.h"
13
14// FORWARD DEFINITION
15
16//! An enumerator of Functions to describe the flow of the Animation
17/**
18   \todo check with Patrick it of
19
20   description in speed to the next keyframe:
21   ANIM_CONSTANT: 0, infinity.
22   ANIM_LINEAR: equal
23   ANIM_SINE: fast, slow, fast
24   ANIM_COSINE: slow, fast, slow
25   ANIM_EXP: slow, fast
26   ANIM_NEG_EXP: fast, slow
27   ANIM_RANDOM: eratic
28
29   ANIM_NULL: !!DO NOT USE THIS!! only for internal handling
30
31   deprecated QUADRATIC
32*/
33typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
34                            ANIM_LINEAR,
35                            ANIM_SINE,
36                            ANIM_COSINE,
37                            ANIM_EXP,
38                            ANIM_NEG_EXP,
39                            ANIM_QUADRATIC,
40                            ANIM_RANDOM,
41                            ANIM_NULL};
42#define ANIM_DEFAULT_FUNCTION ANIM_LINEAR      //!< A default function to choose from the above set
43
44//! An enumerator describing what the animation should do after the last keyframe.
45/**
46   ANIM_INF_CONSTANT stays at the end of the animation
47   ANIM_INF_REPLAY loops back to the beginning and replays the animation
48   ANIM_INF_REWIND loops back to the beginning and then stops the animation
49   ANIM_INF_DELETE deletes the animation. !! THIS IS DANGEROUS !! only do this with non-class variables
50*/
51typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT,
52                            ANIM_INF_REPLAY,
53                            ANIM_INF_REWIND,
54                            ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG;
55
56//! A Superclass for describing an animation (all animations will be derived from this one)
57/** implement in subclasses:
58 *
59 * De-/Constructor
60 * Animation Functions
61 * virtual tick
62 * addKeyFrame
63 * List of keyFrames
64 * currentKeyFrame/nextKeyFrame
65 * virtual rewind, to go to the first Keyframe. (other functions will call this one)
66*/
67class Animation
68{
69 public:
70  virtual ~Animation(void);
71  void doNotHandle(void);
72
73  void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
74
75  void play(); // equals resume();
76  void playNextKeyframes(int n = 1);
77  void stop();
78  void pause();
79  void replay();
80  //! A virtual function that should change to the first keyframe.
81  virtual void rewind() = 0;
82  /** \brief A virtual function that ticks the animation \param dt the time passed */
83  virtual void tick(float dt) = 0;
84
85  /**
86     \returns the BaseObject, this animation operates on
87  */
88  BaseObject* getBaseObject(void) const {return baseObject;}
89
90  /** \returns if the Animation should be deleted */
91  inline bool ifDelete(void) {return bDelete;}
92
93 protected:
94  Animation(void);
95
96  void handleInfinity(void);
97  // variables
98  float localTime;                //!< The Time passed since the beginning of the currentKeyFrame.
99  ANIM_INFINITY postInfinity;     //!< describing what the animation should do after the last keyframe.
100
101  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
102  unsigned int keyFrameCount;     //!< The Count of KeyFrames.
103  int keyFramesToPlay;            //!< How many more Keyframes to play. if negative it will be ignored if 0 stop.
104  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
105  bool bRunning;                  //!< If the animation is running
106  bool bDelete;                   //!< If true, the animation will be deleted through the AnimationPlayer.
107};
108
109
110/**********************TEST*******************************/
111class aTest
112{
113 public:
114  aTest() { last = 0.0;}
115  ~aTest() {}
116  void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
117 private:
118  float diff;
119  float last;
120};
121
122//aTest::aTest() {}
123//aTest::~aTest() {}
124
125//void aTest::littleDebug(float f)
126
127/**********************TEST*******************************/
128
129
130#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.