]> git.tdb.fi Git - libs/gl.git/blob - source/animationplayer.cpp
Don't link program with the transform feature in constructor
[libs/gl.git] / source / animationplayer.cpp
1 #include "animatedobject.h"
2 #include "animationplayer.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace GL {
8
9 void AnimationPlayer::play(AnimatedObject &obj, const Animation &anim)
10 {
11         slots.push_back(Slot(obj, anim));
12 }
13
14 void AnimationPlayer::tick(const Time::TimeDelta &dt)
15 {
16         for(list<Slot>::iterator i=slots.begin(); i!=slots.end(); )
17         {
18                 i->iterator += dt;
19                 i->object.set_matrix(i->iterator.get_matrix());
20
21                 if(i->iterator.is_end())
22                         slots.erase(i++);
23                 else
24                         ++i;
25         }
26 }
27
28
29 AnimationPlayer::Slot::Slot(AnimatedObject &o, const Animation &a):
30         object(o),
31         animation(a),
32         iterator(animation)
33 { }
34
35 } // namespace GL
36 } // namespace Msp