Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4485 was 4485, checked in by bensch, 19 years ago

orxonox/trunk: more documentation in util

File size: 4.2 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
83  /** \brief A virtual function that ticks the animation \param dt the time passed */
84  virtual void tick(float dt) = 0;
85
86  /** \returns the BaseObject, this animation operates on */
87  BaseObject* getBaseObject(void) const { return this->baseObject; };
88
89  /** \returns if the Animation should be deleted */
90  inline bool ifDelete(void) { return bDelete; };
91
92 protected:
93  Animation(void);
94
95  void handleInfinity(void);
96
97 protected:
98  // variables
99  float                 localTime;              //!< The Time passed since the beginning of the currentKeyFrame.
100  ANIM_INFINITY         postInfinity;           //!< describing what the animation should do after the last keyframe.
101
102  BaseObject*           baseObject;             //!< The same as object in the derived classes, but with reference to BaseObject
103  unsigned int          keyFrameCount;          //!< The Count of KeyFrames.
104  int                   keyFramesToPlay;        //!< How many more Keyframes to play. if negative it will be ignored if 0 stop.
105  bool                  bHandled;               //!< If this Animation is handled by the AnimationPlayer.
106  bool                  bRunning;               //!< If the animation is running
107  bool                  bDelete;                //!< If true, the animation will be deleted through the AnimationPlayer.
108};
109
110
111
112
113/**********************TEST*******************************/
114//! a simple testClass for the animation
115class aTest
116{
117 public:
118  inline aTest() { last = 0.0;}
119  /** \brief a little debug information to show the results of this class \param f new value */
120  inline void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
121 private:
122  float     diff;           //!< difference from the last value
123  float     last;           //!< the last calculated value
124};
125
126//aTest::aTest() {}
127//aTest::~aTest() {}
128
129//void aTest::littleDebug(float f)
130
131/**********************TEST*******************************/
132
133
134#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.