Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: naming of animation changed
Anim → Animation
tAnim → tAnimation
Animation → Animation3D

@paede: i hope you like it.

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