]> git.tdb.fi Git - libs/gl.git/blob - source/animationplayer.h
Basic animation support
[libs/gl.git] / source / animationplayer.h
1 #ifndef MSP_GL_ANIMATIONPLAYER_H_
2 #define MSP_GL_ANIMATIONPLAYER_H_
3
4 #include <msp/time/timedelta.h>
5 #include "animation.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class AnimatedObject;
11
12 /**
13 The bridge between Animations and AnimatedObjects.  A single AnimationPlayer
14 can handle an arbitrary number of animations simultaneously.
15 */
16 class AnimationPlayer
17 {
18 private:
19         struct Slot
20         {
21                 AnimatedObject &object;
22                 const Animation &animation;
23                 Animation::Iterator iterator;
24
25                 Slot(AnimatedObject &, const Animation &);
26         };
27
28         std::list<Slot> slots;
29
30 public:
31         /** Plays an animation on an object. */
32         void play(AnimatedObject &, const Animation &);
33
34         /** Advances all playing animations.  Should be called in a regular manner,
35         preferably just before rendering. */
36         void tick(const Time::TimeDelta &);
37 };
38
39 } // namespace GL
40 } // namespace Msp
41
42 #endif