Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: weapon now works perfectly: it shoots and moves to it. now i will have to change the projectile model itself….

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 {
[3750]44
[3738]45  WorldEntity* object;
46  Vector* lastPosition;
47  Vector* tmpVect;
[3750]48  float deltaT;
49  float localTime;
50
[3738]51  tList<KeyFrame>* frames;
[3750]52  KeyFrame* currentFrame;
53  KeyFrame* lastFrame;
54
55  bool bRunning;
56
[3738]57  animationMode animMode;
58  movementMode movMode;
59};
[3573]60
61//! Animation Class
62/**
63   Helps you making some small animation
64*/
65class SimpleAnimation : public BaseObject {
66 
67 public:
[3727]68  static SimpleAnimation* getInstance();
[3752]69  virtual ~SimpleAnimation();
[3573]70
[3729]71  void animatorBegin();
72  void animatorEnd();
[3727]73  void selectObject(WorldEntity* entity);
[3729]74  void addKeyFrame(Vector* point, Quaternion* direction, float time);
75  void addKeyFrame(Vector* point, Quaternion* direction, float time, movementMode mode);
[3573]76  void addKeyFrame(KeyFrame* frame);
[3752]77  void setAnimationMode(animationMode mode);
[3573]78  void reset();
79
[3727]80
[3573]81  void start();
82  void stop();
83  void restart();
84  void pause();
85  void resume();
86
87  void tick(float time);
88
89 private:
[3727]90  SimpleAnimation();
91
92  static SimpleAnimation* singletonRef;
[3733]93  bool bDescriptive;               //<! is true, when AnimatorBegin() was executed but no AnimatorEnd() yet: in describtive mode: pass commands
[3719]94  bool bRunning;                   //<! is set, when the animation is running
[3717]95  tList<KeyFrame>* frames;         //<! where keyframes are stored in
[3738]96  tList<Animation>* animators;      //<! a list of animation's
[3717]97  KeyFrame* currentFrame;          //<! the frame that is been played now
[3719]98  KeyFrame* lastFrame;
[3729]99  Vector* lastPosition;
[3717]100  movementMode mode;               //<! this is an enum of the mode, how the speed is distributed
[3573]101  float localTime;
102  PNode* parent;
103 
[3726]104  Vector* tmpVect;                 //<! this is the temporary vector save place -
[3727]105  WorldEntity* workingObject;      //<! this is a pointer to the current working object that has been selected via selectObject()
[3739]106  Animation* workingAnimator;       //<! the animator with which you are currently working
[3733]107  float deltaT;                    //<! this is a time constant for the movement
108
[3739]109  Animation* getAnimationFromWorldEntity(WorldEntity* entity);
110
[3573]111};
112
113#endif /* _SIMPLE_ANIMATION_H */
Note: See TracBrowser for help on using the repository browser.