Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: moved likely to compiler.h in defs
also reset all the UNLIKELY_IF functions to how they should look.

the old approach is still valid, but depricated.

@patrick: i hope this is ok for you, for it is LINUX-standard.
and i think windows is also able to handle likely/unlikely because it is a compiler issue not a system issue

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