1 /***************************************************************************
2                           Animation.h  -  description
3                              -------------------
4     begin                : Wed Jan 26 2000
5     copyright            : (C) 2000 by
6     email                :
7  ***************************************************************************/
8 
9 #ifndef STDANIMATION_H
10 #define STDANIMATION_H
11 
12 #define EM_TYPE_STDANIMATION 1001
13 
14 #define EM_ROTATION		1
15 #define EM_TRANSLATION	2
16 #define EM_LIGHT 4
17 #define EM_BILLBOARD_SIZE 8
18 
19 #include <vector>
20 
21 #include "EMath.h"
22 #include "Behavior.h"
23 #include "StateMachine.h"
24 
25 class Group;
26 
27 /**
28  * Animation moves or rotates a group according to a given path.
29  *
30  * Animation is represented as list of "x, y, z" points.
31  * The x, y, z can be a translation or a rotation.
32  * Each time the engines render method is called the animation
33  * object will interpolate the group it is attached to, from one point
34  * to an other. When the animation has reached its end it will
35  * start over.
36  *
37  * Usage.
38  * Points are added to the animation with the 'add' method.
39  * The order of the points will be same in which they are added
40  * to the animation.
41  *
42  * Example:
43  * 	Group* group = new Group();
44  *	StdAnimation anim = new StdAnimation(20, E_TRANSLATION);
45  *
46  *  anim->add(0, 0, 0);
47  *	anim->add(100, 0, 0);
48  *	anim->add(0, 100, 0);
49  *  anim->setEnd(0, 0, 0);
50  *
51  *  group->addBehavior(anim);
52  *
53  * This example will create an animation which moves the group from origo to (100, 0 ,0)
54  * and then to (0, 100, 0) and back towards origo. Each movement will last for 20 engine
55  * ticks. When it reaches the end it will start over again.
56  * @see Group
57  */
58 class StdAnimation : public Behavior {
59 	public:
60   /** Animation(step, type). */
61   StdAnimation(int step, int type);
62   ~StdAnimation();
63   void onTick();
64   void add(float, float, float);
65   void setEnd(float, float, float);
66   /** Sets the end point to the first point. */
67   void setEndStart();
setStep(int s)68   inline void setStep(int s) {	m_iStep = s; };
getStep()69   inline int getStep() { return m_iStep; };
setAnimType(int t)70   inline void setAnimType(int t) { m_iAnimType = t; };
clear()71   inline void clear() { m_vVertex.clear(); };
StdEmptyOnSignal()72   void StdEmptyOnSignal() {};
StdEmptyOnCollision()73   void StdEmptyOnCollision() {};
74  private:
75   vector<Vertex3D> m_vVertex;
76   int m_iStep;
77   int m_iTick;
78   int m_iIndex;
79   int m_iAnimType;
80   Vertex3D m_vtxEnd;
81 };
82 
83 #endif // ANIMATION_H
84