]> git.tdb.fi Git - libs/gl.git/blobdiff - source/animatedobject.cpp
Add a class to unify loading coordinate transforms
[libs/gl.git] / source / animatedobject.cpp
index 257e1368def51c6c3a40fef4ebd5f04473320ff9..3a78110009bc2c47b8cf26e9ab7ee59013444b40 100644 (file)
@@ -6,6 +6,7 @@
 #include "programdata.h"
 #include "renderer.h"
 #include "technique.h"
+#include "transform.h"
 
 using namespace std;
 
@@ -79,6 +80,9 @@ void AnimatedObject::setup_render(Renderer &renderer, const Tag &) const
 AnimatedObject::Loader::Loader(AnimatedObject &o):
        DataFile::ObjectLoader<AnimatedObject>(o)
 {
+       add("transform", &Loader::transform);
+
+       // Deprecated; Use the transform statement instead
        add("position", &Loader::position);
        add("rotation", &Loader::rotation);
        add("scale", &Loader::scale);
@@ -105,5 +109,12 @@ void AnimatedObject::Loader::scale_uniform(float s)
        obj.matrix.scale(s);
 }
 
+void AnimatedObject::Loader::transform()
+{
+       Transform trn;
+       load_sub(trn);
+       obj.matrix = trn.to_matrix();
+}
+
 } // namespace GL
 } // namespace Msp