Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/simple_animation.h @ 3747

Last change on this file since 3747 was 3744, checked in by patrick, 20 years ago

orxonox/trunk: SimpleAnimation works again :)

File size: 2.9 KB
RevLine 
[3573]1/*!
2    \file simple_animation.h
3    \brief A class to interpolate the movement of an object following descrete points in room and time
4    \todo implement it
5
6    This class has been done to animate some movement, works best for short
7    distances.
8*/
9
10#ifndef _SIMPLE_ANIMATION_H
11#define _SIMPLE_ANIMATION_H
12
13#include "base_object.h"
14#include "list.h"
15
16
[3726]17class Vector;
18class Quaternion;
19class WorldEntity;
20class PNode;
21
[3717]22typedef enum movementMode{LINEAR=0, EXP, NEG_EXP, SIN, COS, QUADRATIC};
[3738]23typedef enum animationMode{SINGLE=0, LOOP};
[3726]24#define DEFAULT_ANIMATION_MODE LINEAR
[3573]25
[3738]26
[3726]27//! KeyFrame Struct
[3573]28/**
[3729]29   This represents one point with direction of the animation
[3573]30*/
[3726]31typedef struct KeyFrame {
32  Vector* position;
[3729]33  Quaternion* direction;
[3726]34  WorldEntity* object;
[3573]35  float time;
36  movementMode mode;
37};
38
[3738]39//! Animation Struct
40/**
41   This represents an animation for a object
42*/
43typedef struct Animation {
44  WorldEntity* object;
45  KeyFrame* currentFrame;
46  KeyFrame* lastFrame;
47  Vector* lastPosition;
48  Vector* tmpVect;
49  tList<KeyFrame>* frames;
50  animationMode animMode;
51  movementMode movMode;
52  bool bRunning;
53  float deltaT;
[3744]54  float localTime;
[3738]55};
[3573]56
57//! Animation Class
58/**
59   Helps you making some small animation
60*/
61class SimpleAnimation : public BaseObject {
62 
63 public:
[3727]64  static SimpleAnimation* getInstance();
[3573]65
[3729]66  void animatorBegin();
67  void animatorEnd();
[3727]68  void selectObject(WorldEntity* entity);
[3729]69  void addKeyFrame(Vector* point, Quaternion* direction, float time);
70  void addKeyFrame(Vector* point, Quaternion* direction, float time, movementMode mode);
[3573]71  void addKeyFrame(KeyFrame* frame);
72  void reset();
73
[3727]74
[3573]75  void start();
76  void stop();
77  void restart();
78  void pause();
79  void resume();
80
81  void tick(float time);
82
83 private:
[3727]84  SimpleAnimation();
85  virtual ~SimpleAnimation();
86
87  static SimpleAnimation* singletonRef;
[3733]88  bool bDescriptive;               //<! is true, when AnimatorBegin() was executed but no AnimatorEnd() yet: in describtive mode: pass commands
[3719]89  bool bRunning;                   //<! is set, when the animation is running
[3717]90  tList<KeyFrame>* frames;         //<! where keyframes are stored in
[3738]91  tList<Animation>* animators;      //<! a list of animation's
[3717]92  KeyFrame* currentFrame;          //<! the frame that is been played now
[3719]93  KeyFrame* lastFrame;
[3729]94  Vector* lastPosition;
[3717]95  movementMode mode;               //<! this is an enum of the mode, how the speed is distributed
[3573]96  float localTime;
97  PNode* parent;
98 
[3726]99  Vector* tmpVect;                 //<! this is the temporary vector save place -
[3727]100  WorldEntity* workingObject;      //<! this is a pointer to the current working object that has been selected via selectObject()
[3739]101  Animation* workingAnimator;       //<! the animator with which you are currently working
[3733]102  float deltaT;                    //<! this is a time constant for the movement
103
[3739]104  Animation* getAnimationFromWorldEntity(WorldEntity* entity);
105
[3573]106};
107
108#endif /* _SIMPLE_ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.