diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-13 20:44:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-13 20:44:59 +0400 |
commit | ff5c86fcc343ef8bfa208d4594712ce53fac6b9e (patch) | |
tree | 877d7fe0a39e9499f434d9cf0a80e17ed3ecefea /io_scene_fbx | |
parent | 7ff0b59e875f3fe2dc3b7980f754a47c25ee41bf (diff) |
option to export only deforming bones (defaults to True for Unity3D)
Diffstat (limited to 'io_scene_fbx')
-rw-r--r-- | io_scene_fbx/__init__.py | 5 | ||||
-rw-r--r-- | io_scene_fbx/export_fbx.py | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index f2ee6cbb..f3862f7c 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -132,6 +132,11 @@ class ExportFBX(bpy.types.Operator, ExportHelper): "pipeline errors with XNA"), default=False, ) + use_armature_deform_only = BoolProperty( + name="Only Deform Bones", + description="Only write deforming bones", + default=False, + ) use_anim = BoolProperty( name="Include Animation", description="Export keyframe animation", diff --git a/io_scene_fbx/export_fbx.py b/io_scene_fbx/export_fbx.py index 33d120ae..c71ba3cd 100644 --- a/io_scene_fbx/export_fbx.py +++ b/io_scene_fbx/export_fbx.py @@ -216,6 +216,7 @@ def save_single(operator, scene, filepath="", object_types={'EMPTY', 'CAMERA', 'LAMP', 'ARMATURE', 'MESH'}, use_mesh_modifiers=True, mesh_smooth_type='FACE', + use_armature_deform_only=False, use_anim=True, use_anim_optimize=True, anim_optimize_precision=6, @@ -2098,11 +2099,30 @@ def save_single(operator, scene, filepath="", # fbxName, blenderObject, my_bones, blenderActions #ob_arms[i] = fbxArmObName, ob, arm_my_bones, (ob.action, []) + if use_armature_deform_only: + # tag non deforming bones that have no deforming children + deform_map = dict.fromkeys(my_arm.blenData.bones, False) + for bone in my_arm.blenData.bones: + if bone.use_deform: + deform_map[bone] = True + # tag all parents, even ones that are not deform since their child _is_ + for parent in bone.parent_recursive: + deform_map[parent] = True + for bone in my_arm.blenData.bones: + + if use_armature_deform_only: + # if this bone doesnt deform, and none of its children deform, skip it! + if not deform_map[bone]: + continue + my_bone = my_bone_class(bone, my_arm) my_arm.fbxBones.append(my_bone) ob_bones.append(my_bone) + if use_armature_deform_only: + del deform_map + # add the meshes to the bones and replace the meshes armature with own armature class #for obname, ob, mtx, me, mats, arm, armname in ob_meshes: for my_mesh in ob_meshes: @@ -2932,6 +2952,7 @@ def defaults_unity3d(): use_selection=False, object_types={'ARMATURE', 'EMPTY', 'MESH'}, use_mesh_modifiers=True, + use_armature_deform_only=True, use_anim=True, use_anim_optimize=False, use_anim_action_all=True, |