[Bf-extensions-cvs] [f63d9de] master: DirectX format, use matrix_basis for the original rotation

Chris Foster cdbfoster at gmail.com
Wed Apr 15 08:43:20 CEST 2015


Campbell,

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.

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).

In practice, this causes a bone to do a 180 degree flip between adjacent
frames during rotations of >180 degrees.

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.

Chris

On Wed, Apr 15, 2015 at 12:44 AM, Campbell Barton <noreply at git.blender.org>
wrote:

> Commit: f63d9de38b7e85ae5f0c93d419b10e7789b6bd3a
> Author: Campbell Barton
> Date:   Wed Apr 15 14:42:59 2015 +1000
> Branches: master
> https://developer.blender.org/rBAf63d9de38b7e85ae5f0c93d419b10e7789b6bd3a
>
> DirectX format, use matrix_basis for the original rotation
>
> ===================================================================
>
> M       io_scene_x/export_x.py
>
> ===================================================================
>
> diff --git a/io_scene_x/export_x.py b/io_scene_x/export_x.py
> index fb17106..8c67538 100644
> --- a/io_scene_x/export_x.py
> +++ b/io_scene_x/export_x.py
> @@ -1146,7 +1146,7 @@ class
> ArmatureAnimationGenerator(GenericAnimationGenerator):
>
>                  Rotation = ArmatureObject.data.bones[Bone.name] \
>                      .matrix.to_quaternion() * \
> -                    Bone.rotation_quaternion
> +                    Bone.matrix_basis.to_quaternion()
>
>                  PoseMatrix = Matrix()
>                  if Bone.parent:
>
> _______________________________________________
> Bf-extensions-cvs mailing list
> Bf-extensions-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-extensions-cvs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-extensions-cvs/attachments/20150415/a71ce820/attachment.htm 


More information about the Bf-extensions-cvs mailing list