2 #include <msp/strings/format.h>
3 #include "animatedobject.h"
5 #include "programdata.h"
14 AnimatedObject::AnimatedObject(const Object &o):
18 if(const Technique *tech = object.get_technique())
19 if(tech->has_shaders())
20 shdata = new ProgramData;
23 AnimatedObject::~AnimatedObject()
28 void AnimatedObject::set_matrix(const Matrix &m)
33 void AnimatedObject::set_pose_matrix(unsigned link, const Matrix &m)
37 if(link*16>=pose_data.size())
38 pose_data.resize((link+1)*16);
39 copy(m.data(), m.data()+16, &pose_data[link*16]);
40 shdata->uniform_matrix4_array("pose[0]", pose_data.size()/16, &pose_data[0]);
44 void AnimatedObject::setup_render(Renderer &renderer, const Tag &) const
46 renderer.matrix_stack() *= matrix;
48 renderer.add_shader_data(*shdata);
52 AnimatedObject::Loader::Loader(AnimatedObject &o):
53 DataFile::ObjectLoader<AnimatedObject>(o)
55 add("position", &Loader::position);
56 add("rotation", &Loader::rotation);
57 add("scale", &Loader::scale);
58 add("scale", &Loader::scale_uniform);
61 void AnimatedObject::Loader::position(float x, float y, float z)
63 obj.matrix.translate(x, y, z);
66 void AnimatedObject::Loader::rotation(float a, float x, float y, float z)
68 obj.matrix.rotate_deg(a, x, y, z);
71 void AnimatedObject::Loader::scale(float x, float y, float z)
73 obj.matrix.scale(x, y, z);
76 void AnimatedObject::Loader::scale_uniform(float s)