Skip to content

Commit

Permalink
Export_3ds: Added apply transform option
Browse files Browse the repository at this point in the history
Added option to apply transformation matrix before export
  • Loading branch information
nrgsille76 committed May 4, 2024
1 parent b59b4da commit dd084d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 10 additions & 3 deletions io_scene_3ds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,15 @@ class Export3DS(bpy.types.Operator, ExportHelper):
('LIGHT', "Light".rjust(12), "", 'LIGHT_DATA',0x4),
('CAMERA', "Camera".rjust(11), "", 'CAMERA_DATA',0x8),
('EMPTY', "Empty".rjust(11), "", 'EMPTY_AXIS',0x10),
('ARMATURE', "Armature".rjust(11), "", 'ARMATURE_DATA', 0x20),
('OTHER', "Other".rjust(12), "", 'MATSHADERBALL', 0x40),
('OTHER', "Other".rjust(12), "", 'MATSHADERBALL', 0x20),
),
description="Object types to export",
default={'WORLD', 'MESH', 'LIGHT', 'CAMERA', 'EMPTY', 'ARMATURE', 'OTHER'},
default={'WORLD', 'MESH', 'LIGHT', 'CAMERA', 'EMPTY', 'OTHER'},
)
use_apply_transform: bpy.props.BoolProperty(
name="Apply Transform",
description="Apply matrix transform before export",
default=True,
)
use_keyframes: BoolProperty(
name="Animation",
Expand Down Expand Up @@ -301,6 +305,9 @@ def export_transform(layout, operator):
line = body.row(align=True)
line.prop(operator, "use_scene_unit")
line.label(text="", icon='EMPTY_ARROWS' if operator.use_scene_unit else 'EMPTY_DATA')
line = body.row(align=True)
line.prop(operator, "use_apply_transform")
line.label(text="", icon='MESH_CUBE' if operator.use_apply_transform else 'MOD_SOLIDIFY')
body.prop(operator, "axis_forward")
body.prop(operator, "axis_up")

Expand Down
14 changes: 8 additions & 6 deletions io_scene_3ds/export_3ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,8 +1555,8 @@ def make_ambient_node(world):
##########

def save(operator, context, filepath="", collection="", scale_factor=1.0, use_scene_unit=False,
use_selection=False, object_filter=None, use_keyframes=True, use_hierarchy=False,
use_collection=False, global_matrix=None, use_cursor=False):
use_selection=False, object_filter=None, use_apply_transform=True, use_keyframes=True,
use_hierarchy=False, use_collection=False, global_matrix=None, use_cursor=False):
"""Save the Blender scene to a 3ds file."""

# Time the export
Expand Down Expand Up @@ -1633,9 +1633,11 @@ def save(operator, context, filepath="", collection="", scale_factor=1.0, use_sc
free_objects = []

if object_filter is None:
object_filter = {'WORLD', 'MESH', 'LIGHT', 'CAMERA', 'EMPTY', 'ARMATURE', 'OTHER'}
object_filter = {'WORLD', 'MESH', 'LIGHT', 'CAMERA', 'EMPTY', 'OTHER'}

if 'OTHER' in object_filter:
object_filter.remove('OTHER')
object_filter |= {'ARMATURE'}
object_filter |= other

if use_selection:
Expand All @@ -1659,7 +1661,7 @@ def save(operator, context, filepath="", collection="", scale_factor=1.0, use_sc
if ob.type not in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META'}:
continue

if ob.type in other:
if ob_derived.type in other:
item = ob_derived.evaluated_get(depsgraph)
data = bpy.data.meshes.new_from_object(item, preserve_all_data_layers=True, depsgraph=depsgraph)
free_objects.append(data)
Expand All @@ -1670,7 +1672,7 @@ def save(operator, context, filepath="", collection="", scale_factor=1.0, use_sc
data = None

if data:
matrix = global_matrix @ mtx
matrix = mtx @ global_matrix if use_apply_transform else global_matrix
data.transform(matrix)
data.transform(mtx_scale)
mesh_objects.append((ob_derived, data, matrix))
Expand Down Expand Up @@ -2047,4 +2049,4 @@ def save(operator, context, filepath="", collection="", scale_factor=1.0, use_sc
# Debugging only: dump the chunk hierarchy
# primary.dump()

return {'FINISHED'}
return {'FINISHED'}

0 comments on commit dd084d4

Please sign in to comment.