[Bf-extensions-cvs] [53d4d40] master: FBX Import: Various minor fixes:

Jens Ch. Restemeier noreply at git.blender.org
Thu Jul 31 22:19:48 CEST 2014


Commit: 53d4d407289045dc45fa7028a2df5b97fef49c1c
Author: Jens Ch. Restemeier
Date:   Thu Jul 31 22:15:57 2014 +0200
Branches: master
https://developer.blender.org/rBA53d4d407289045dc45fa7028a2df5b97fef49c1c

FBX Import: Various minor fixes:

* Fixed error when importing bone attributes without Properties70 child.
* Fixed error when creating alpha material (missing tex_map parameter).
* Added support for bone-parenting.

===================================================================

M	io_scene_fbx/import_fbx.py

===================================================================

diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py
index bb252b2..7e85608 100644
--- a/io_scene_fbx/import_fbx.py
+++ b/io_scene_fbx/import_fbx.py
@@ -707,7 +707,7 @@ def blen_read_animations_action_item(action, item, cnodes, force_global, fps, se
         props = [(item.path_from_id("value"), 1, "Key")]
     else:  # Object or PoseBone:
         if item not in object_tdata_cache:
-            print("ERROR! object '%s' has no transform data, while being animated!" % ob.name)
+            print("ERROR! object '%s' has no transform data, while being animated!" % item.name)
             return
 
         # We want to create actions for objects, but for bones we 'reuse' armatures' actions!
@@ -1748,7 +1748,8 @@ def load(operator, context, filepath="",
                         if fbx_tdata is None or fbx_tdata.id != b'NodeAttribute' or fbx_tdata.props[2] != b'LimbNode':
                             continue
                         fbx_props = (elem_find_first(fbx_tdata, b'Properties70'),)
-                        size = elem_props_get_number(fbx_props, b'Size', default=size)
+                        if fbx_props[0] is not None:  # Some bones have no Properties70 at all...
+                            size = elem_props_get_number(fbx_props, b'Size', default=size)
                         break  # Only one bone data per bone!
 
                     clusters = []
@@ -1912,6 +1913,8 @@ def load(operator, context, filepath="",
     _(); del _
 
     def _():
+        from bpy.types import PoseBone
+
         # Parent objects, after we created them...
         for fbx_uuid, fbx_item in fbx_table_nodes.items():
             if fbx_uuid in fbx_objects_parent_ignore:
@@ -1931,7 +1934,12 @@ def load(operator, context, filepath="",
                  fbx_lnk_item,
                  fbx_lnk_type) in connection_filter_forward(fbx_uuid, b'Model'):
 
-                blen_data.parent = fbx_lnk_item
+                if isinstance(fbx_lnk_item, PoseBone):
+                    blen_data.parent = fbx_lnk_item.id_data  # get the armature the bone belongs to
+                    blen_data.parent_bone = fbx_lnk_item.name
+                    blen_data.parent_type = 'BONE'
+                else:
+                    blen_data.parent = fbx_lnk_item
     _(); del _
 
     def _():
@@ -2208,7 +2216,7 @@ def load(operator, context, filepath="",
                         else:
                             print("WARNING: material link %r ignored" % lnk_type)
 
-                        material_images.setdefault(material, {})[lnk_type] = image
+                        material_images.setdefault(material, {})[lnk_type] = (image, tex_map)
                 else:
                     if fbx_lnk_type.props[0] == b'OP':
                         lnk_type = fbx_lnk_type.props[3]
@@ -2250,7 +2258,7 @@ def load(operator, context, filepath="",
                         else:
                             print("WARNING: material link %r ignored" % lnk_type)
 
-                        material_images.setdefault(material, {})[lnk_type] = image
+                        material_images.setdefault(material, {})[lnk_type] = (image, tex_map)
 
         # Check if the diffuse image has an alpha channel,
         # if so, use the alpha channel.
@@ -2261,7 +2269,7 @@ def load(operator, context, filepath="",
             if fbx_obj.id != b'Material':
                 continue
             material = fbx_table_nodes[fbx_uuid][1]
-            image = material_images.get(material, {}).get(b'DiffuseColor')
+            image, tex_map = material_images.get(material, {}).get(b'DiffuseColor', (None, None))
             # do we have alpha?
             if image and image.depth == 32:
                 if use_alpha_decals:
@@ -2273,7 +2281,7 @@ def load(operator, context, filepath="",
                         ma_wrap.alpha_image_set_from_diffuse()
                 else:
                     if not any((True for mtex in material.texture_slots if mtex and mtex.use_map_alpha)):
-                        mtex = material_mtex_new(material, image)
+                        mtex = material_mtex_new(material, image, tex_map)
 
                         material.use_transparency = True
                         material.transparency_method = 'RAYTRACE'



More information about the Bf-extensions-cvs mailing list