X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fanimationplayer.cpp;h=cbcb6b596f07addcdac87d3f7d6ab8bd3b992af4;hp=13bd7af034a70aa59b4c9b445cb8161640ba969a;hb=42c1534d95e1551c37e64a1dae288e8b75e8d8ba;hpb=332352298ef41b8ac3a4c57b467dd146c0b05e0b diff --git a/source/animationplayer.cpp b/source/animationplayer.cpp index 13bd7af0..cbcb6b59 100644 --- a/source/animationplayer.cpp +++ b/source/animationplayer.cpp @@ -18,7 +18,7 @@ AnimationPlayer::Target &AnimationPlayer::get_slot(Placeable &obj) 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) @@ -31,30 +31,30 @@ AnimationPlayer::Target &AnimationPlayer::play_(Placeable &obj, const Animation 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 @@ -132,7 +132,7 @@ void AnimationPlayer::tick(const Time::TimeDelta &dt) 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) @@ -160,7 +160,7 @@ void AnimationPlayer::tick_stacked(Target &target, const Time::TimeDelta &dt) Matrix matrix = target.base_matrix; for(vector::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) @@ -216,8 +216,9 @@ void AnimationPlayer::set_object_uniform(AnimatedObject &obj, const string &name } -AnimationPlayer::PlayingAnimation::PlayingAnimation(const Animation &a): +AnimationPlayer::PlayingAnimation::PlayingAnimation(const Animation &a, float s): animation(&a), + speed(s), iterator(*animation) { }