]> git.tdb.fi Git - libs/gl.git/blobdiff - source/keyframe.cpp
Add a class to unify loading coordinate transforms
[libs/gl.git] / source / keyframe.cpp
index dd4adf16611efb7c2c05312d0428d949de7c6df5..708fa22bc338e25a478ec11ccc969eccccf37589 100644 (file)
@@ -1,6 +1,7 @@
 #include <msp/datafile/collection.h>
 #include "keyframe.h"
 #include "pose.h"
+#include "transform.h"
 
 using namespace std;
 
@@ -52,11 +53,14 @@ void KeyFrame::Loader::init()
 {
        add("pose", &Loader::pose);
        add("pose", &Loader::pose_inline);
+       add("transform", &Loader::transform);
+       add("uniforms", &Loader::uniforms);
+
+       // Deprecated; use the transform statement instead
        add("position", &Loader::position);
        add("rotation", &Loader::rotation);
        add("scaling", &Loader::scaling_uniform);
        add("scaling", &Loader::scaling);
-       add("uniforms", &Loader::uniforms);
 }
 
 void KeyFrame::Loader::pose(const string &n)
@@ -92,6 +96,13 @@ void KeyFrame::Loader::scaling(float x, float y, float z)
        obj.matrix.scale(x, y, z);
 }
 
+void KeyFrame::Loader::transform()
+{
+       Transform trn;
+       load_sub(trn);
+       obj.matrix = trn.to_matrix();
+}
+
 void KeyFrame::Loader::uniforms()
 {
        UniformsLoader ldr(obj);