Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: rearanged keyFrame-addition

File size: 3.5 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
27   
28   deprecated QUADRATIC
29*/
[3784]30typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
31                            ANIM_LINEAR,
32                            ANIM_SINE,
[3825]33                            ANIM_COSINE,
34                            ANIM_EXP,
35                            ANIM_NEG_EXP,
36                            ANIM_QUADRATIC,
[3784]37                            ANIM_RANDOM};
[3787]38
[3853]39//! An enumerator describing what the animation should do after the last keyframe.
[3858]40/**
41   ANIM_INF_CONSTANT stays at the end of the animation
[3863]42   ANIM_INF_REPLAY loops back to the beginning and replays the animation
43   ANIM_INF_REWIND loops back to the beginning and then stops the animation
44   ANIM_INF_DELETE deletes the animation. !! THIS IS DANGEROUS !! only do this with non-class variables
[3858]45*/
[3784]46typedef enum ANIM_INFINITY {ANIM_INF_CONSTANT,
[3858]47                            ANIM_INF_REPLAY,
[3863]48                            ANIM_INF_REWIND,
[3858]49                            ANIM_INF_DELETE};//, ANIM_INF_LINEAR, ANIM_INF_PINGPONG;
[3543]50
[3853]51//! A Superclass for describing an animation (all animations will be derived from this one)
52/** implement in subclasses:
53 *
54 * De-/Constructor
55 * Animation Functions
56 * virtual tick
[3860]57 * addKeyFrame
[3853]58 * List of keyFrames
59 * currentKeyFrame/nextKeyFrame
60 * virtual rewind, to go to the first Keyframe. (other functions will call this one)
61*/
[3847]62class Animation
[3782]63{
[3785]64 public:
[3847]65  virtual ~Animation(void);
[3820]66  void doNotHandle(void);
[3794]67
68  void setInfinity(ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
69
70  void play(); // equals resume();
71  void stop();
72  void pause();
73  void replay();
[3853]74  //! A virtual function that should change to the first keyframe.
[3797]75  virtual void rewind() = 0;
[3853]76  /** \brief A virtual function that ticks the animation \param dt the time passed */
[3852]77  virtual void tick(float dt) = 0;
[3794]78
[3833]79  /**
80     \returns the BaseObject, this animation operates on
81  */
[3851]82  BaseObject* getBaseObject(void) const {return baseObject;}
[3833]83
[3860]84  /** \returns if the Animation should be deleted */
85  inline bool ifDelete(void) {return bDelete;}
86
[3782]87 protected:
[3847]88  Animation(void);
[3782]89
[3858]90  void handleInfinity(void);
[3784]91  // variables
[3853]92  float localTime;                //!< The Time passed since the beginning of the currentKeyFrame.
93  ANIM_INFINITY postInfinity;     //!< describing what the animation should do after the last keyframe.
[3794]94
[3833]95  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
[3876]96  unsigned int keyFrameCount;     //!< The Count of KeyFrames.
[3820]97  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
[3853]98  bool bRunning;                  //!< If the animation is running
[3860]99  bool bDelete;                   //!< If true, the animation will be deleted through the AnimationPlayer.
[3782]100};
101
102
[3833]103/**********************TEST*******************************/
104class aTest
105{
106 public:
107  aTest() { last = 0.0;}
108  ~aTest() {}
109  void littleDebug(float f) {  diff = f - last; printf("f=%f, diff=%f\n", f,diff); last = f;}
110 private:
111  float diff;
112  float last;
113};
114
115//aTest::aTest() {}
116//aTest::~aTest() {}
117
118//void aTest::littleDebug(float f)
119
120/**********************TEST*******************************/
121
122
[3781]123#endif /* _ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.