Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/animation.h @ 3858

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

orxonox/trunk: moved the infinity-handling into animation.cc

File size: 3.3 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
12// FORWARD DEFINITION
13
14#define DELTA_X 0.05  //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta
15
16//! An enumerator of Functions to describe the flow of the Animation
17typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
18                            ANIM_LINEAR,
19                            ANIM_SINE,
20                            ANIM_COSINE,
21                            ANIM_EXP,
22                            ANIM_NEG_EXP,
23                            ANIM_QUADRATIC,
24                            ANIM_RANDOM};
25
26//! An enumerator describing what the animation should do after the last keyframe.
27/**
28   ANIM_INF_CONSTANT stays at the end of the animation
29   ANIM_INF_REWIND loops back to the beginning and replays the animation
30*/
31typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT,
32                            ANIM_INF_REPLAY,
33                            ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG;
34
35//! A Struct for Keyframes that simply hold a float
36typedef struct KeyFrameF
37{
38  float duration;             //!< duration of this keyframe
39  float value;                //!< value of this keyframe
40  ANIM_FUNCTION animFunc;     //!< with whitch function to iterate to the next KeyFrameF
41};
42
43//! A Superclass for describing an animation (all animations will be derived from this one)
44/** implement in subclasses:
45 *
46 * De-/Constructor
47 * Animation Functions
48 * virtual tick
49 * List of keyFrames
50 * currentKeyFrame/nextKeyFrame
51 * virtual rewind, to go to the first Keyframe. (other functions will call this one)
52*/
53class Animation
54{
55 public:
56  virtual ~Animation(void);
57  void doNotHandle(void);
58
59  void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
60
61  void play(); // equals resume();
62  void stop();
63  void pause();
64  void replay();
65  //! A virtual function that should change to the first keyframe.
66  virtual void rewind() = 0;
67  /** \brief A virtual function that ticks the animation \param dt the time passed */
68  virtual void tick(float dt) = 0;
69
70  /**
71     \returns the BaseObject, this animation operates on
72  */
73  BaseObject* getBaseObject(void) const {return baseObject;}
74
75 protected:
76  Animation(void);
77
78  void handleInfinity(void);
79  // variables
80  float localTime;                //!< The Time passed since the beginning of the currentKeyFrame.
81  ANIM_INFINITY postInfinity;     //!< describing what the animation should do after the last keyframe.
82
83  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
84  bool bHasKeys;                  //!< If the animation has any keys at all. Needed to add the first keyframe (and delete the dummy).
85  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
86  bool bRunning;                  //!< If the animation is running
87  //  bool bDelete;                   //!< If true, the animation will be deleted through the AnimationPlayer.
88};
89
90
91/**********************TEST*******************************/
92class aTest
93{
94 public:
95  aTest() { last = 0.0;}
96  ~aTest() {}
97  void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
98 private:
99  float diff;
100  float last;
101};
102
103//aTest::aTest() {}
104//aTest::~aTest() {}
105
106//void aTest::littleDebug(float f)
107
108/**********************TEST*******************************/
109
110
111#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.