Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3733 was 3733, checked in by patrick, 21 years ago

orxonox/trunk: SimpleAnimation - the NEG_EXP function works also now.

File size: 2.3 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};
23#define DEFAULT_ANIMATION_MODE LINEAR
24
25//! KeyFrame Struct
26/**
27   This represents one point with direction of the animation
28*/
29typedef struct KeyFrame {
30  Vector* position;
31  Quaternion* direction;
32  WorldEntity* object;
33  float time;
34  movementMode mode;
35};
36
37
38//! Animation Class
39/**
40   Helps you making some small animation
41*/
42class SimpleAnimation : public BaseObject {
43 
44 public:
45  static SimpleAnimation* getInstance();
46
47  void animatorBegin();
48  void animatorEnd();
49  void selectObject(WorldEntity* entity);
50  void addKeyFrame(Vector* point, Quaternion* direction, float time);
51  void addKeyFrame(Vector* point, Quaternion* direction, float time, movementMode mode);
52  void addKeyFrame(KeyFrame* frame);
53  void reset();
54
55
56  void start();
57  void stop();
58  void restart();
59  void pause();
60  void resume();
61
62  void tick(float time);
63
64 private:
65  SimpleAnimation();
66  virtual ~SimpleAnimation();
67
68  static SimpleAnimation* singletonRef;
69  bool bDescriptive;               //<! is true, when AnimatorBegin() was executed but no AnimatorEnd() yet: in describtive mode: pass commands
70  bool bRunning;                   //<! is set, when the animation is running
71  tList<KeyFrame>* frames;         //<! where keyframes are stored in
72  KeyFrame* currentFrame;          //<! the frame that is been played now
73  KeyFrame* lastFrame;
74  Vector* lastPosition;
75  movementMode mode;               //<! this is an enum of the mode, how the speed is distributed
76  float localTime;
77  PNode* parent;
78 
79  Vector* tmpVect;                 //<! this is the temporary vector save place -
80  WorldEntity* workingObject;      //<! this is a pointer to the current working object that has been selected via selectObject()
81  float deltaT;                    //<! this is a time constant for the movement
82
83};
84
85#endif /* _SIMPLE_ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.