17 Animate::Animate(GL::Placeable &t, const GL::Animation &a, GL::AnimationPlayer &p, bool s):
25 void Animate::validate() const
28 throw logic_error("null target");
30 throw logic_error("null animation");
32 throw logic_error("null player");
35 void Animate::start(float, float d)
38 if(!anim->is_looping() && d)
39 speed = (anim->get_duration()/Time::sec)/d;
43 player->play_stacked(*target_obj, *anim, speed);
45 player->play(*target_obj, *anim, speed);
50 player->play_stacked(*target, *anim, speed);
52 player->play(*target, *anim, speed);
56 void Animate::end(float)
58 player->stop(*target, *anim);
62 Animate::Loader::Loader(Animate &a, Demo &d):
63 DataFile::DerivedObjectLoader<Animate, Action::Loader>(a, d)
65 a.player = &demo.get_animation_player();
66 add("animation", &Loader::animation);
67 add("stacked", &Animate::stacked);
68 add("target", &Loader::target);
71 void Animate::Loader::animation(const string &n)
73 obj.anim = &demo.get_resources().get<GL::Animation>(n);
76 void Animate::Loader::target(const string &n)
78 obj.target = &demo.get_thing<GL::Placeable>(n);
79 obj.target_obj = dynamic_cast<GL::AnimatedObject *>(obj.target);
82 } // namespace DemoScene