Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 4344 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
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();
[3982]75  void playNextKeyframes(int n = 1);
[3794]76  void stop();
77  void pause();
78  void replay();
[3853]79  //! A virtual function that should change to the first keyframe.
[3797]80  virtual void rewind() = 0;
[3853]81  /** \brief A virtual function that ticks the animation \param dt the time passed */
[3852]82  virtual void tick(float dt) = 0;
[3794]83
[3833]84  /**
85     \returns the BaseObject, this animation operates on
86  */
[3851]87  BaseObject* getBaseObject(void) const {return baseObject;}
[3833]88
[3860]89  /** \returns if the Animation should be deleted */
90  inline bool ifDelete(void) {return bDelete;}
91
[3782]92 protected:
[3847]93  Animation(void);
[3782]94
[3858]95  void handleInfinity(void);
[3784]96  // variables
[3853]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.
[3794]99
[3833]100  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
[3876]101  unsigned int keyFrameCount;     //!< The Count of KeyFrames.
[3982]102  int keyFramesToPlay;            //!< How many more Keyframes to play. if negative it will be ignored if 0 stop.
[3820]103  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
[3853]104  bool bRunning;                  //!< If the animation is running
[3860]105  bool bDelete;                   //!< If true, the animation will be deleted through the AnimationPlayer.
[3782]106};
107
108
[3833]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
[3781]129#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.