<div dir="ltr"><div><div><div>Campbell,<br></div><div><br>The reason that rotation_quaternion was used instead of matrix_basis.to_quaternion() is that quaternions generated by converting this matrix cannot be interpolated between.<br><br></div>For instance, while Matrix.Rotation(pi, 4, 'X').to_quaternion() and Quaternion((cos(pi / 2), sin(pi / 2), 0, 0)) both produce (0, 1, 0, 0), angles greater than 180 degrees produce different quaternions, as can be seen in Matrix.Rotation(5 * pi / 4, 4, 'X').to_quaternion(), which produces (0.3827, -0.9239, 0, 0), and Quaternion((cos(5 * pi / 8), sin(5 * pi / 8), 0, 0)), which produces (-0.3827, 0.9239, 0, 0).<br><br></div><div>In practice, this causes a bone to do a 180 degree flip between adjacent frames during rotations of >180 degrees.<br></div><div><br></div>For this reason, I relied on rotation_quaternion to give me a correctly signed representation of the rotation. If there's a more robust method for doing so, please let me know. Otherwise, let me know if I can re-apply my changes.<br><br></div>Chris<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 12:44 AM, Campbell Barton <span dir="ltr"><<a href="mailto:noreply@git.blender.org" target="_blank">noreply@git.blender.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Commit: f63d9de38b7e85ae5f0c93d419b10e7789b6bd3a<br>
Author: Campbell Barton<br>
Date: Wed Apr 15 14:42:59 2015 +1000<br>
Branches: master<br>
<a href="https://developer.blender.org/rBAf63d9de38b7e85ae5f0c93d419b10e7789b6bd3a" target="_blank">https://developer.blender.org/rBAf63d9de38b7e85ae5f0c93d419b10e7789b6bd3a</a><br>
<br>
DirectX format, use matrix_basis for the original rotation<br>
<br>
===================================================================<br>
<br>
M io_scene_x/export_x.py<br>
<br>
===================================================================<br>
<br>
diff --git a/io_scene_x/export_x.py b/io_scene_x/export_x.py<br>
index fb17106..8c67538 100644<br>
--- a/io_scene_x/export_x.py<br>
+++ b/io_scene_x/export_x.py<br>
@@ -1146,7 +1146,7 @@ class ArmatureAnimationGenerator(GenericAnimationGenerator):<br>
<br>
Rotation = ArmatureObject.data.bones[Bone.name] \<br>
.matrix.to_quaternion() * \<br>
- Bone.rotation_quaternion<br>
+ Bone.matrix_basis.to_quaternion()<br>
<br>
PoseMatrix = Matrix()<br>
if Bone.parent:<br>
<br>
_______________________________________________<br>
Bf-extensions-cvs mailing list<br>
<a href="mailto:Bf-extensions-cvs@blender.org">Bf-extensions-cvs@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-extensions-cvs" target="_blank">http://lists.blender.org/mailman/listinfo/bf-extensions-cvs</a><br>
</blockquote></div><br></div>