diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-15 22:10:06 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-15 22:10:06 +0300 |
commit | ffaddb3a6f59dc9a2177c27391c8fd8444af3257 (patch) | |
tree | 7d0a89d2706a5a3543e077fe50c40f135f0e596b /io_scene_fbx/export_fbx_bin.py | |
parent | 02b82c4fc10d1755fb3176b2aae66d060eea6015 (diff) |
Final step (hopefully) in unit/scale Hell.
So, it appears some importers (at least UE4) do not use UnitScaleFactor defined by FBX,
which is assumed to be a way to say 'this FBX file uses units n times default FBX unit'
(default FBX unit being centimeter - afaik, at least I saw some FBX from Max with a
UnitScaleFactor of 2.54 - inches).
Hence, we have to add yet another stupid option to apply that 'unit scaling' to objects
instead (as part of global scaling)... Hurra.
Diffstat (limited to 'io_scene_fbx/export_fbx_bin.py')
-rw-r--r-- | io_scene_fbx/export_fbx_bin.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py index e6d5f720..1e6aa383 100644 --- a/io_scene_fbx/export_fbx_bin.py +++ b/io_scene_fbx/export_fbx_bin.py @@ -2613,9 +2613,13 @@ 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_org = units_blender_to_fbx_factor(scene) - scale_factor = scene_data.settings.global_scale * units_blender_to_fbx_factor(scene) + if scene_data.settings.apply_unit_scale: + # Unit scaling is applied to objects' scale, so our unit is effectively FBX one (centimeter). + scale_factor_org = 1.0 + scale_factor = scene_data.settings.global_scale / units_blender_to_fbx_factor(scene) + else: + scale_factor_org = units_blender_to_fbx_factor(scene) + scale_factor = scene_data.settings.global_scale * units_blender_to_fbx_factor(scene) elem_props_set(props, "p_integer", b"UpAxis", up_axis[0]) elem_props_set(props, "p_integer", b"UpAxisSign", up_axis[1]) elem_props_set(props, "p_integer", b"FrontAxis", front_axis[0]) @@ -2799,6 +2803,7 @@ def fbx_takes_elements(root, scene_data): # This func can be called with just the filepath def save_single(operator, scene, filepath="", global_matrix=Matrix(), + apply_unit_scale=False, axis_up="Z", axis_forward="Y", context_objects=None, @@ -2834,7 +2839,8 @@ def save_single(operator, scene, filepath="", if 'OTHER' in object_types: object_types |= BLENDER_OTHER_OBJECT_TYPES - #~ global_matrix = global_matrix * Matrix.Scale(units_blender_to_fbx_factor(scene), 4) + if apply_unit_scale: + global_matrix = global_matrix * Matrix.Scale(units_blender_to_fbx_factor(scene), 4) global_scale = global_matrix.median_scale global_matrix_inv = global_matrix.inverted() # For transforming mesh normals. @@ -2869,7 +2875,7 @@ def save_single(operator, scene, filepath="", ) settings = FBXExportSettings( - operator.report, (axis_up, axis_forward), global_matrix, global_scale, + operator.report, (axis_up, axis_forward), global_matrix, global_scale, apply_unit_scale, bake_space_transform, global_matrix_inv, global_matrix_inv_transposed, context_objects, object_types, use_mesh_modifiers, mesh_smooth_type, use_mesh_edges, use_tspace, |