[Bf-extensions-cvs] [87e9510] master: FBX Export: Hopefully fix once and for all default scale issue.

Bastien Montagne noreply at git.blender.org
Tue May 19 15:45:13 CEST 2015


Commit: 87e95103c5165634eead5e6a2cdb7c68079f26db
Author: Bastien Montagne
Date:   Tue May 19 15:42:24 2015 +0200
Branches: master
https://developer.blender.org/rBA87e95103c5165634eead5e6a2cdb7c68079f26db

FBX Export: Hopefully fix once and for all default scale issue.

Now, we consider default BU as 1 meter (100 FBX units), instead of 1 FBX unit (1cm)...

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

M	io_scene_fbx/__init__.py
M	io_scene_fbx/export_fbx_bin.py

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

diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py
index abd542b..1d613b4 100644
--- a/io_scene_fbx/__init__.py
+++ b/io_scene_fbx/__init__.py
@@ -21,7 +21,7 @@
 bl_info = {
     "name": "FBX format",
     "author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
-    "version": (3, 3, 0),
+    "version": (3, 3, 1),
     "blender": (2, 74, 0),
     "location": "File > Import-Export",
     "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index e1ed2ed..ff8581c 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -2602,7 +2602,7 @@ def fbx_header_elements(root, scene_data, time=None):
     props = elem_properties(global_settings)
     up_axis, front_axis, coord_axis = RIGHT_HAND_AXES[scene_data.settings.to_axes]
     # Currently not sure about that, but looks like default unit of FBX is cm...
-    #~ scale_factor = (1.0 if scene.unit_settings.system == 'NONE' else scene.unit_settings.scale_length) * 100 * scene_data.settings.global_scale
+    scale_factor_org = 100.0 if (scene.unit_settings.system == 'NONE') else (100.0 * scene.unit_settings.scale_length)
     scale_factor = scene_data.settings.global_scale
     elem_props_set(props, "p_integer", b"UpAxis", up_axis[0])
     elem_props_set(props, "p_integer", b"UpAxisSign", up_axis[1])
@@ -2613,7 +2613,7 @@ def fbx_header_elements(root, scene_data, time=None):
     elem_props_set(props, "p_integer", b"OriginalUpAxis", -1)
     elem_props_set(props, "p_integer", b"OriginalUpAxisSign", 1)
     elem_props_set(props, "p_double", b"UnitScaleFactor", scale_factor)
-    elem_props_set(props, "p_double", b"OriginalUnitScaleFactor", 1.0)
+    elem_props_set(props, "p_double", b"OriginalUnitScaleFactor", scale_factor_org)
     elem_props_set(props, "p_color_rgb", b"AmbientColor", (0.0, 0.0, 0.0))
     elem_props_set(props, "p_string", b"DefaultCamera", "Producer Perspective")
 
@@ -2825,8 +2825,9 @@ def save_single(operator, scene, filepath="",
     # Scale/unit mess. FBX can store the 'reference' unit of a file in its UnitScaleFactor property
     # (1.0 meaning centimeter, afaik). We use that to reflect user's default unit as set in Blender with scale_length.
     # However, we always get values in BU (i.e. meters), so we have to reverse-apply that scale in global matrix...
-    if scene.unit_settings.system != 'NONE':
-        global_matrix = global_matrix * Matrix.Scale(1.0 / scene.unit_settings.scale_length, 4)
+    # Note that when no default unit is available, we assume 'meters' (and hence scale by 100).
+    scale_correction = 100.0 if (scene.unit_settings.system == 'NONE') else (100.0 * scene.unit_settings.scale_length)
+    global_matrix = global_matrix * Matrix.Scale(scale_correction, 4)
     global_scale = global_matrix.median_scale
     global_matrix_inv = global_matrix.inverted()
     # For transforming mesh normals.



More information about the Bf-extensions-cvs mailing list