X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fanimatedobject.cpp;h=3a1d9d836ffea98989b79936f87a8ebe8034e20b;hb=6db6b7e49848e6bbc14f3ec8113ee5a941e4af07;hp=e4aa00445f4b42f83f63400b798772aa583777c1;hpb=7c1315191bc96298d1664f80fa3e2cb5a34339fa;p=libs%2Fgl.git diff --git a/source/animatedobject.cpp b/source/animatedobject.cpp index e4aa0044..3a1d9d83 100644 --- a/source/animatedobject.cpp +++ b/source/animatedobject.cpp @@ -20,6 +20,11 @@ AnimatedObject::AnimatedObject(const Object &o): shdata = new ProgramData; } +AnimatedObject::~AnimatedObject() +{ + delete shdata; +} + void AnimatedObject::set_matrix(const Matrix &m) { matrix = m; @@ -38,9 +43,39 @@ void AnimatedObject::set_pose_matrix(unsigned link, const Matrix &m) void AnimatedObject::setup_render(Renderer &renderer, const Tag &) const { - renderer.matrix_stack() *= matrix; + renderer.transform(matrix); if(shdata) - renderer.add_shader_data(shdata); + renderer.add_shader_data(*shdata); +} + + +AnimatedObject::Loader::Loader(AnimatedObject &o): + DataFile::ObjectLoader(o) +{ + add("position", &Loader::position); + add("rotation", &Loader::rotation); + add("scale", &Loader::scale); + add("scale", &Loader::scale_uniform); +} + +void AnimatedObject::Loader::position(float x, float y, float z) +{ + obj.matrix.translate(x, y, z); +} + +void AnimatedObject::Loader::rotation(float a, float x, float y, float z) +{ + obj.matrix.rotate_deg(a, x, y, z); +} + +void AnimatedObject::Loader::scale(float x, float y, float z) +{ + obj.matrix.scale(x, y, z); +} + +void AnimatedObject::Loader::scale_uniform(float s) +{ + obj.matrix.scale(s); } } // namespace GL