X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fanimate.cpp;h=a7e406d73ae80c3428b5fe91d214820dffc645bf;hb=4b2708d0a743f74dfc44ea4e4c08344e09c624a6;hp=d74c23920da32b08c720f5cded62459e1f588ce5;hpb=34051ffdca091ad3971c1382c71c5fc58b7ade0f;p=libs%2Fdemoscene.git diff --git a/source/animate.cpp b/source/animate.cpp index d74c239..a7e406d 100644 --- a/source/animate.cpp +++ b/source/animate.cpp @@ -2,17 +2,23 @@ #include "demo.h" using namespace std; -using namespace Msp; + +namespace Msp { +namespace DemoScene { Animate::Animate(): target(0), + target_obj(0), anim(0), + stacked(false), player(0) { } -Animate::Animate(GL::Placeable &t, const GL::Animation &a, GL::AnimationPlayer &p): +Animate::Animate(GL::Placeable &t, const GL::Animation &a, GL::AnimationPlayer &p, bool s): target(&t), + target_obj(0), anim(&a), + stacked(s), player(&p) { } @@ -28,8 +34,23 @@ void Animate::validate() const void Animate::start(float, float d) { - float speed = (d ? (anim->get_duration()/Time::sec)/d : 1.0f); - player->play(*target, *anim, speed); + float speed = 1.0f; + if(!anim->is_looping() && d) + speed = (anim->get_duration()/Time::sec)/d; + if(target_obj) + { + if(stacked) + player->play_stacked(*target_obj, *anim, speed); + else + player->play(*target_obj, *anim, speed); + } + else + { + if(stacked) + player->play_stacked(*target, *anim, speed); + else + player->play(*target, *anim, speed); + } } @@ -38,6 +59,7 @@ Animate::Loader::Loader(Animate &a, Demo &d): { a.player = &demo.get_animation_player(); add("animation", &Loader::animation); + add("stacked", &Animate::stacked); add("target", &Loader::target); } @@ -49,4 +71,8 @@ void Animate::Loader::animation(const string &n) void Animate::Loader::target(const string &n) { obj.target = &demo.get_thing(n); + obj.target_obj = dynamic_cast(obj.target); } + +} // namespace DemoScene +} // namespace Msp