[Bf-python] Partly fixed the official FBX plugin

Art Golf artgolf1000 at gmail.com
Wed Oct 22 08:37:35 CEST 2014


Hi,

This is my first post, I have been trying to fix the issues of the official FBX plugin in Blender 2.72, and I have a few good news to you :-)

Solution one:

Open this python script (Mac)

/Applications/Blender/blender.app/Contents/Resources/2.72/scripts/addons/io_scene_fbx/import_fbx.py

Replace the line of
ebo.tail = Vector((0.0, 1.0, 0.0)) * max(bsize, 1e-3)

With
ebo.tail = Vector((0.0, 1e-3, 0.0))

The boring long bones will appear as small points, you can change armature’s display mode to ’Stick’ mode, the joints will display as small yellow cubes, you may easily select and operate the joints now.

Solution Two:

I have written a piece of python script to fix the directions of the imported bones, the script works, but has small issue to be fixed.

Here is the script:
———————————————————————————————————
import bpy
from mathutils import Matrix, Vector
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
for arm in bpy.data.armatures:
    for bone in arm.edit_bones:
        # no child
        if len(bone.children) == 0:
            # ignore single joint
            if bone.parent is not None:
                trivial_length = (bone.head - bone.parent.head).magnitude * 1e-1
                # toward Y, trivial length
                bone.tail = bone.head + Vector((0.0, trivial_length, 0.0))
        # one child
        elif len(bone.children) == 1:
            bone.tail = bone.children[0].head
        # more children
        else:
            # use the average distance to its children as its length
            average_length = 0.0
            for child in bone.children:
                average_length = average_length + (bone.head - child.head).magnitude
            average_length = average_length / len(bone.children)
            # toward Y, average length
            bone.tail = bone.head + Vector((0.0, average_length, 0.0))
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
———————————————————————————————————

To run the script, you must select the armature in OBJECT mode, then switch to the script window, paste and run it.

You may find that the directions of all bones have been fixed immediately, but a few bones may rolled slightly.

The issue is that, when the position of the bone tail changes, the matrix of the bone will changes slightly, this will cause the bone roll slightly.

If there exists a way to lock the matrix of a bone when changing the position of its tail, the issue will be fixed.

Can we just change the position of the bone tail while don’t change anything else?

Art

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-python/attachments/20141022/b3620774/attachment.html>


More information about the Bf-python mailing list