diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index c268ea0492492447079d2186948d83356fd98616..238d536e2184d55ad61588bae4e237bfd7397b11 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -177,6 +177,12 @@ class ImportFBX(bpy.types.Operator, ImportHelper): default='X', ) + use_prepost_rot = BoolProperty( + name="Use Pre/Post Rotation", + description="Use pre/post rotation from FBX transform (you may have to disable that in some cases)", + default=True, + ) + def draw(self, context): layout = self.layout @@ -205,6 +211,8 @@ class ImportFBX(bpy.types.Operator, ImportHelper): sub.prop(self, "primary_bone_axis") sub.prop(self, "secondary_bone_axis") + layout.prop(self, "use_prepost_rot") + def execute(self, context): keywords = self.as_keywords(ignore=("filter_glob", "directory")) keywords["use_cycles"] = (context.scene.render.engine == 'CYCLES') diff --git a/io_scene_fbx/fbx_utils.py b/io_scene_fbx/fbx_utils.py index 8ab4b2a9a5d2bfc7d3fe98e5c5bc142390e677d1..e8837fc9bdf4b2e36468163e705829b5f1ddfa26 100644 --- a/io_scene_fbx/fbx_utils.py +++ b/io_scene_fbx/fbx_utils.py @@ -1150,5 +1150,5 @@ FBXImportSettings = namedtuple("FBXImportSettings", ( "use_alpha_decals", "decal_offset", "use_custom_props", "use_custom_props_enum_as_string", "cycles_material_wrap_map", "image_cache", - "ignore_leaf_bones", "automatic_bone_orientation", "bone_correction_matrix" + "ignore_leaf_bones", "automatic_bone_orientation", "bone_correction_matrix", "use_prepost_rot", )) diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index 11f76ac5ff5283684894d2bfd611d3aa69952a29..e3ccd9a9e9b95d22cbd65043ddb74f52f947fd7f 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -382,7 +382,7 @@ def add_vgroup_to_objects(vg_indices, vg_weights, vg_name, objects): vg.add((i,), w, 'REPLACE') -def blen_read_object_transform_preprocess(fbx_props, fbx_obj, rot_alt_mat): +def blen_read_object_transform_preprocess(fbx_props, fbx_obj, rot_alt_mat, use_prepost_rot): # This is quite involved, 'fbxRNode.cpp' from openscenegraph used as a reference const_vector_zero_3d = 0.0, 0.0, 0.0 const_vector_one_3d = 1.0, 1.0, 1.0 @@ -399,8 +399,12 @@ def blen_read_object_transform_preprocess(fbx_props, fbx_obj, rot_alt_mat): is_rot_act = elem_props_get_bool(fbx_props, b'RotationActive', False) if is_rot_act: - pre_rot = elem_props_get_vector_3d(fbx_props, b'PreRotation', const_vector_zero_3d) - pst_rot = elem_props_get_vector_3d(fbx_props, b'PostRotation', const_vector_zero_3d) + if use_prepost_rot: + pre_rot = elem_props_get_vector_3d(fbx_props, b'PreRotation', const_vector_zero_3d) + pst_rot = elem_props_get_vector_3d(fbx_props, b'PostRotation', const_vector_zero_3d) + else: + pre_rot = const_vector_zero_3d + pst_rot = const_vector_zero_3d rot_ord = { 0: 'XYZ', 1: 'XYZ', @@ -1862,7 +1866,8 @@ def load(operator, context, filepath="", ignore_leaf_bones=False, automatic_bone_orientation=False, primary_bone_axis='Y', - secondary_bone_axis='X'): + secondary_bone_axis='X', + use_prepost_rot=True): global fbx_elem_nil fbx_elem_nil = FBXElem('', (), (), ()) @@ -1975,6 +1980,7 @@ def load(operator, context, filepath="", use_custom_props, use_custom_props_enum_as_string, cycles_material_wrap_map, image_cache, ignore_leaf_bones, automatic_bone_orientation, bone_correction_matrix, + use_prepost_rot, ) # #### And now, the "real" data. @@ -2155,7 +2161,7 @@ def load(operator, context, filepath="", elem_find_first(fbx_tmpl, b'Properties70', fbx_elem_nil)) assert(fbx_props[0] is not None) - transform_data = blen_read_object_transform_preprocess(fbx_props, fbx_obj, Matrix()) + transform_data = blen_read_object_transform_preprocess(fbx_props, fbx_obj, Matrix(), use_prepost_rot) is_bone = fbx_obj.props[2] in {b'LimbNode', b'Root'} fbx_helper_nodes[a_uuid] = FbxImportHelperNode(fbx_obj, bl_data, transform_data, is_bone)