Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/md2_loader/src/util/animation/animation.h @ 4225

Last change on this file since 4225 was 3982, checked in by bensch, 20 years ago

orxonox/trunk: now there is a posibility to play only parts of the animation:
use anim→playNextKeyframes(count_of_keyframes_to_play); to make it work

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