Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: nicer implementation, also fool-proof now

File size: 3.6 KB
RevLine 
[3781]1/*!
2    \file animation.h
[3849]3    A Subclass for all animations in orxonox
[3781]4*/
5
6#ifndef _ANIMATION_H
7#define _ANIMATION_H
8
[3795]9#include "list.h"
[3833]10#include "base_object.h"
[3863]11#include "confincl.h"  // must be here to determin the DEBUG-level
[3833]12
[3782]13// FORWARD DEFINITION
14
[3853]15//! An enumerator of Functions to describe the flow of the Animation
[3863]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
[3867]24   ANIM_EXP: slow, fast
25   ANIM_NEG_EXP: fast, slow
[3863]26   ANIM_RANDOM: eratic
[3978]27
28   ANIM_NULL: !!DO NOT USE THIS!! only for internal handling
29
[3863]30   deprecated QUADRATIC
31*/
[3784]32typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
33                            ANIM_LINEAR,
34                            ANIM_SINE,
[3825]35                            ANIM_COSINE,
36                            ANIM_EXP,
37                            ANIM_NEG_EXP,
38                            ANIM_QUADRATIC,
[3978]39                            ANIM_RANDOM,
40                            ANIM_NULL};
[3979]41#define ANIM_DEFAULT_FUNCTION ANIM_LINEAR      //!< A default function to choose from the above set
[3787]42
[3853]43//! An enumerator describing what the animation should do after the last keyframe.
[3858]44/**
45   ANIM_INF_CONSTANT stays at the end of the animation
[3863]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
[3858]49*/
[3784]50typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT,
[3858]51                            ANIM_INF_REPLAY,
[3863]52                            ANIM_INF_REWIND,
[3858]53                            ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG;
[3543]54
[3853]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
[3860]61 * addKeyFrame
[3853]62 * List of keyFrames
63 * currentKeyFrame/nextKeyFrame
64 * virtual rewind, to go to the first Keyframe. (other functions will call this one)
65*/
[3847]66class Animation
[3782]67{
[3785]68 public:
[3847]69  virtual ~Animation(void);
[3820]70  void doNotHandle(void);
[3794]71
72  void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
73
74  void play(); // equals resume();
75  void stop();
76  void pause();
77  void replay();
[3853]78  //! A virtual function that should change to the first keyframe.
[3797]79  virtual void rewind() = 0;
[3853]80  /** \brief A virtual function that ticks the animation \param dt the time passed */
[3852]81  virtual void tick(float dt) = 0;
[3794]82
[3833]83  /**
84     \returns the BaseObject, this animation operates on
85  */
[3851]86  BaseObject* getBaseObject(void) const {return baseObject;}
[3833]87
[3860]88  /** \returns if the Animation should be deleted */
89  inline bool ifDelete(void) {return bDelete;}
90
[3782]91 protected:
[3847]92  Animation(void);
[3782]93
[3858]94  void handleInfinity(void);
[3784]95  // variables
[3853]96  float localTime;                //!< The Time passed since the beginning of the currentKeyFrame.
97  ANIM_INFINITY postInfinity;     //!< describing what the animation should do after the last keyframe.
[3794]98
[3833]99  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
[3876]100  unsigned int keyFrameCount;     //!< The Count of KeyFrames.
[3820]101  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
[3853]102  bool bRunning;                  //!< If the animation is running
[3860]103  bool bDelete;                   //!< If true, the animation will be deleted through the AnimationPlayer.
[3782]104};
105
106
[3833]107/**********************TEST*******************************/
108class aTest
109{
110 public:
111  aTest() { last = 0.0;}
112  ~aTest() {}
113  void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
114 private:
115  float diff;
116  float last;
117};
118
119//aTest::aTest() {}
120//aTest::~aTest() {}
121
122//void aTest::littleDebug(float f)
123
124/**********************TEST*******************************/
125
126
[3781]127#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.