Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: changed (void) → ()

File size: 4.1 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
34{
35  ANIM_CONSTANT,
36  ANIM_LINEAR,
37  ANIM_SINE,
38  ANIM_COSINE,
39  ANIM_EXP,
40  ANIM_NEG_EXP,
41  ANIM_QUADRATIC,
42  ANIM_RANDOM,
43  ANIM_NULL
44};
45
46#define ANIM_DEFAULT_FUNCTION ANIM_LINEAR      //!< A default function to choose from the above set
47
48//! An enumerator describing what the animation should do after the last keyframe.
49/**
50   ANIM_INF_CONSTANT stays at the end of the animation
51   ANIM_INF_REPLAY loops back to the beginning and replays the animation
52   ANIM_INF_REWIND loops back to the beginning and then stops the animation
53   ANIM_INF_DELETE deletes the animation. !! THIS IS DANGEROUS !! only do this with non-class variables
54*/
55typedef enum ANIM_INFINITY
56{
57  ANIM_INF_CONSTANT,
58  ANIM_INF_REPLAY,
59  ANIM_INF_REWIND,
60  ANIM_INF_DELETE
61}; //, ANIM_INF_LINEAR, ANIM_INF_PINGPONG};
62
63//! A Superclass for describing an animation (all animations will be derived from this one)
64/** implement in subclasses:
65 *
66 * De-/Constructor
67 * Animation Functions
68 * virtual tick
69 * addKeyFrame
70 * List of keyFrames
71 * currentKeyFrame/nextKeyFrame
72 * virtual rewind, to go to the first Keyframe. (other functions will call this one)
73*/
74class Animation : public BaseObject
75{
76 public:
77  virtual ~Animation();
78  void doNotHandle();
79
80  void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
81
82  void play(); // equals resume();
83  void playNextKeyframes(int n = 1);
84  void stop();
85  void pause();
86  void replay();
87  //! A virtual function that should change to the first keyframe.
88  virtual void rewind() = 0;
89
90  /** \brief A virtual function that ticks the animation \param dt the time passed */
91  virtual void tick(float dt) = 0;
92
93  /** \returns the BaseObject, this animation operates on */
94  BaseObject* getBaseObject() const { return this->baseObject; };
95
96  /** \returns if the Animation should be deleted */
97  inline bool ifDelete() { return bDelete; };
98
99 protected:
100  Animation();
101
102  void handleInfinity();
103
104 protected:
105  // variables
106  float                 localTime;              //!< The Time passed since the beginning of the currentKeyFrame.
107  ANIM_INFINITY         postInfinity;           //!< describing what the animation should do after the last keyframe.
108
109  BaseObject*           baseObject;             //!< The same as object in the derived classes, but with reference to BaseObject
110  unsigned int          keyFrameCount;          //!< The Count of KeyFrames.
111  int                   keyFramesToPlay;        //!< How many more Keyframes to play. if negative it will be ignored if 0 stop.
112  bool                  bHandled;               //!< If this Animation is handled by the AnimationPlayer.
113  bool                  bRunning;               //!< If the animation is running
114  bool                  bDelete;                //!< If true, the animation will be deleted through the AnimationPlayer.
115};
116
117
118
119
120/**********************TEST*******************************/
121//! a simple testClass for the animation
122class aTest
123{
124 public:
125  inline aTest() { last = 0.0;}
126  /** \brief a little debug information to show the results of this class \param f new value */
127  inline void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
128 private:
129  float     diff;           //!< difference from the last value
130  float     last;           //!< the last calculated value
131};
132
133//aTest::aTest() {}
134//aTest::~aTest() {}
135
136//void aTest::littleDebug(float f)
137
138/**********************TEST*******************************/
139
140
141#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.