Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/qt_gui/src/util/animation/animation.h @ 7626

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

orxonox/trunk: merged the christmas branche to the trunk
merged with command:
svn merge -r6165:HEAD christmas_branche/ ../trunk/
no conflicts

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