Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: made some sattelite object just for fun and to show on the convention tomarrow

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