Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3980 was 3979, checked in by bensch, 20 years ago

orxonox/trunk: nicer implementation, also fool-proof now

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