]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pose.cpp
Require the first keyframe of an animation to be at zero offset
[libs/gl.git] / source / pose.cpp
index b5c5781b630be2365c5dcb06841acd3060291180..99fa6bb3dfe812265a8e2372ddd9c1daad5f887a 100644 (file)
@@ -37,7 +37,7 @@ void Pose::rotate_link(unsigned i, float angle, const Vector3 &axis)
        // Keep the base point stationary
        Vector3 base = arm_link.get_base();
        Vector3 new_base = links[i].local_matrix*base;
-       links[i].local_matrix.translate(base.x-new_base.x, base.y-new_base.y, base.z-new_base.z);
+       links[i].local_matrix = Matrix::translation(base-new_base)*links[i].local_matrix;
 
        if(const Armature::Link *parent = arm_link.get_parent())
                links[i].matrix = links[parent->get_index()].matrix*links[i].local_matrix;
@@ -56,14 +56,19 @@ const Matrix &Pose::get_link_matrix(unsigned i) const
 Pose::Loader::Loader(Pose &p, Collection &c):
        DataFile::CollectionObjectLoader<Pose>(p, &c)
 {
-       add("armature", &Pose::armature);
+       add("armature", &Loader::armature);
        add("link",     &Loader::link);
 }
 
+void Pose::Loader::armature(const string &n)
+{
+       obj.set_armature(get_collection().get<Armature>(n));
+}
+
 void Pose::Loader::link(const string &n)
 {
        if(!obj.armature)
-               error("Armature must be specified first");
+               throw logic_error("Armature must be specified first");
        LinkLoader ldr(obj, obj.armature->get_link(n).get_index());
        load_sub_with(ldr);
 }