return objects.insert(ObjectMap::value_type(&obj, Target(obj))).first->second;
}
-AnimationPlayer::Target &AnimationPlayer::play_(Placeable &obj, const Animation &anim, bool stacked)
+AnimationPlayer::Target &AnimationPlayer::play_(Placeable &obj, const Animation &anim, bool stacked, float speed)
{
Target &target = get_slot(obj);
if(!stacked)
target.stacked = stacked;
// TODO check for incompatible armature
target.armature = anim.get_armature();
- target.animations.push_back(PlayingAnimation(anim));
+ target.animations.push_back(PlayingAnimation(anim, speed));
return target;
}
-void AnimationPlayer::play(AnimatedObject &obj, const Animation &anim)
+void AnimationPlayer::play(AnimatedObject &obj, const Animation &anim, float speed)
{
- Target &target = play_(obj, anim, false);
+ Target &target = play_(obj, anim, false, speed);
target.object = &obj;
}
-void AnimationPlayer::play(Placeable &obj, const Animation &anim)
+void AnimationPlayer::play(Placeable &obj, const Animation &anim, float speed)
{
- play_(obj, anim, false);
+ play_(obj, anim, false, speed);
}
-void AnimationPlayer::play_stacked(AnimatedObject &obj, const Animation &anim)
+void AnimationPlayer::play_stacked(AnimatedObject &obj, const Animation &anim, float speed)
{
- Target &target = play_(obj, anim, true);
+ Target &target = play_(obj, anim, true, speed);
target.object = &obj;
}
-void AnimationPlayer::play_stacked(Placeable &obj, const Animation &anim)
+void AnimationPlayer::play_stacked(Placeable &obj, const Animation &anim, float speed)
{
- play_(obj, anim, true);
+ play_(obj, anim, true, speed);
}
unsigned AnimationPlayer::get_n_active_animations(const AnimatedObject &obj) const
}
}
-void AnimationPlayer::stop(AnimatedObject &obj)
+void AnimationPlayer::stop(Placeable &obj)
{
objects.erase(&obj);
}
-void AnimationPlayer::stop(AnimatedObject &obj, const Animation &anim)
+void AnimationPlayer::stop(Placeable &obj, const Animation &anim)
{
ObjectMap::iterator i = objects.find(&obj);
if(i==objects.end())
void AnimationPlayer::tick_single(Target &target, const Time::TimeDelta &dt)
{
PlayingAnimation &anim = target.animations.front();
- anim.iterator += dt;
+ anim.iterator += dt*anim.speed;
target.placeable.set_matrix(anim.iterator.get_matrix());
if(target.object)
Matrix matrix = target.base_matrix;
for(vector<PlayingAnimation>::iterator i=target.animations.begin(); i!=target.animations.end(); ++i)
{
- i->iterator += dt;
+ i->iterator += dt*i->speed;
matrix *= i->iterator.get_matrix();
if(target.object)
shdata.uniform(name, uni.values[0]);
else if(uni.size==2)
shdata.uniform2(name, uni.values);
- else if(uni.size==2)
+ else if(uni.size==3)
shdata.uniform3(name, uni.values);
else if(uni.size==4)
shdata.uniform4(name, uni.values);
}
-AnimationPlayer::PlayingAnimation::PlayingAnimation(const Animation &a):
+AnimationPlayer::PlayingAnimation::PlayingAnimation(const Animation &a, float s):
animation(&a),
+ speed(s),
iterator(*animation)
{ }