1 #ifndef MSP_GL_ANIMATIONPLAYER_H_
2 #define MSP_GL_ANIMATIONPLAYER_H_
4 #include <msp/time/timedelta.h>
14 The bridge between Animations and AnimatedObjects. A single AnimationPlayer
15 can handle an arbitrary number of animations simultaneously.
22 const Animation *animation;
23 Animation::Iterator iterator;
25 AnimationSlot(const Animation &);
30 AnimatedObject &object;
32 const Armature *armature;
33 std::vector<AnimationSlot> animations;
36 ObjectSlot(AnimatedObject &);
39 typedef std::map<const AnimatedObject *, ObjectSlot> ObjectMap;
44 ObjectSlot &get_slot(AnimatedObject &);
47 /// Plays an animation on an object. Any previous animations are replaced.
48 void play(AnimatedObject &, const Animation &);
50 /** Plays an animation, stacked with other animations. If no animations are
51 playing yet, the object's current matrix is used as the base. */
52 void play_stacked(AnimatedObject &, const Animation &);
54 /// Returns the number of animations currently affecting an object.
55 unsigned get_n_active_animations(const AnimatedObject &) const;
57 /// Stops all animations affecting an object.
58 void stop(AnimatedObject &);
60 /// Stops a single animation affecting an object.
61 void stop(AnimatedObject &, const Animation &);
63 /** Advances all playing animations. Should be called in a regular manner,
64 preferably just before rendering. */
65 void tick(const Time::TimeDelta &);
68 bool tick_single(ObjectSlot &, const Time::TimeDelta &);
69 bool tick_stacked(ObjectSlot &, const Time::TimeDelta &);
70 static void set_object_uniform(AnimatedObject &, const std::string &, const KeyFrame::AnimatedUniform &);