]> git.tdb.fi Git - libs/gl.git/blobdiff - source/animationplayer.h
Basic animation support
[libs/gl.git] / source / animationplayer.h
diff --git a/source/animationplayer.h b/source/animationplayer.h
new file mode 100644 (file)
index 0000000..fe53a35
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef MSP_GL_ANIMATIONPLAYER_H_
+#define MSP_GL_ANIMATIONPLAYER_H_
+
+#include <msp/time/timedelta.h>
+#include "animation.h"
+
+namespace Msp {
+namespace GL {
+
+class AnimatedObject;
+
+/**
+The bridge between Animations and AnimatedObjects.  A single AnimationPlayer
+can handle an arbitrary number of animations simultaneously.
+*/
+class AnimationPlayer
+{
+private:
+       struct Slot
+       {
+               AnimatedObject &object;
+               const Animation &animation;
+               Animation::Iterator iterator;
+
+               Slot(AnimatedObject &, const Animation &);
+       };
+
+       std::list<Slot> slots;
+
+public:
+       /** Plays an animation on an object. */
+       void play(AnimatedObject &, const Animation &);
+
+       /** Advances all playing animations.  Should be called in a regular manner,
+       preferably just before rendering. */
+       void tick(const Time::TimeDelta &);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif