00001 #ifndef ANIMATION_H
00002 #define ANIMATION_H
00003
00004 #include "Component.h"
00005 #include "CGLA\Vec3f.h"
00006 #include <vector>
00007 #include <map>
00008
00009 using namespace CGLA;
00010 using namespace std;
00011
00012 class Transform;
00013
00017 struct KeyFrame{
00018 float time;
00019 Vec3f* rotations;
00020 KeyFrame* next;
00021 };
00022
00027 struct AnimationClip{
00028 int fade;
00029 bool loop;
00030 bool playing;
00031 string name;
00032 KeyFrame* first;
00033 KeyFrame* current;
00034 int nbBones;
00035 Transform** bones;
00036 };
00037
00042 class Animation: public Component{
00043 public:
00044 Animation();
00045 ~Animation();
00046
00050 void addClip(const AnimationClip& clip);
00051
00055 void play(const string& clip);
00056 void pause();
00057
00061 void fadeIn(const string& clip);
00065 void fadeOut(const string& clip);
00066
00070 void animate(float t);
00071 protected:
00072 bool playing;
00073
00077 vector<AnimationClip*> clips;
00081 map<string,AnimationClip> clipsmap;
00082
00086 vector<float> weights;
00087
00091 vector<float> startTimes;
00095 map<Transform*,Vec3f> blendedRotations;
00096
00097
00098 };
00099
00100 #endif