Sun Position: fix error in HDRI mode when no env tex is selected
[blender-addons.git] / io_scene_3ds / __init__.py
blobefe2e6d67b9269fcc11b95d5c4e4c4b19df9f7e0
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 from bpy_extras.io_utils import (
4 ImportHelper,
5 ExportHelper,
6 orientation_helper,
7 axis_conversion,
9 from bpy.props import (
10 BoolProperty,
11 EnumProperty,
12 FloatProperty,
13 StringProperty,
15 import bpy
16 bl_info = {
17 "name": "Autodesk 3DS format",
18 "author": "Bob Holcomb, Campbell Barton, Andreas Atteneder, Sebastian Schrand",
19 "version": (2, 3, 2),
20 "blender": (3, 6, 0),
21 "location": "File > Import",
22 "description": "3DS Import/Export meshes, UVs, materials, textures, "
23 "cameras & lamps",
24 "warning": "Images must be in file folder, "
25 "filenames are limited to DOS 8.3 format",
26 "doc_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
27 "Scripts/Import-Export/Autodesk_3DS",
28 "category": "Import-Export",
31 if "bpy" in locals():
32 import importlib
33 if "import_3ds" in locals():
34 importlib.reload(import_3ds)
35 if "export_3ds" in locals():
36 importlib.reload(export_3ds)
39 @orientation_helper(axis_forward='Y', axis_up='Z')
40 class Import3DS(bpy.types.Operator, ImportHelper):
41 """Import from 3DS file format (.3ds)"""
42 bl_idname = "import_scene.autodesk_3ds"
43 bl_label = 'Import 3DS'
44 bl_options = {'UNDO'}
46 filename_ext = ".3ds"
47 filter_glob: StringProperty(default="*.3ds", options={'HIDDEN'})
49 constrain_size: FloatProperty(
50 name="Size Constraint",
51 description="Scale the model by 10 until it reaches the "
52 "size constraint (0 to disable)",
53 min=0.0, max=1000.0,
54 soft_min=0.0, soft_max=1000.0,
55 default=10.0,
57 use_image_search: BoolProperty(
58 name="Image Search",
59 description="Search subdirectories for any associated images "
60 "(Warning, may be slow)",
61 default=True,
63 use_apply_transform: BoolProperty(
64 name="Apply Transform",
65 description="Workaround for object transformations "
66 "importing incorrectly",
67 default=True,
69 read_keyframe: bpy.props.BoolProperty(
70 name="Read Keyframe",
71 description="Read the keyframe data",
72 default=True,
74 use_world_matrix: bpy.props.BoolProperty(
75 name="World Space",
76 description="Transform to matrix world",
77 default=False,
80 def execute(self, context):
81 from . import import_3ds
83 keywords = self.as_keywords(ignore=("axis_forward",
84 "axis_up",
85 "filter_glob",
88 global_matrix = axis_conversion(from_forward=self.axis_forward,
89 from_up=self.axis_up,
90 ).to_4x4()
91 keywords["global_matrix"] = global_matrix
93 return import_3ds.load(self, context, **keywords)
96 @orientation_helper(axis_forward='Y', axis_up='Z')
97 class Export3DS(bpy.types.Operator, ExportHelper):
98 """Export to 3DS file format (.3ds)"""
99 bl_idname = "export_scene.autodesk_3ds"
100 bl_label = 'Export 3DS'
102 filename_ext = ".3ds"
103 filter_glob: StringProperty(
104 default="*.3ds",
105 options={'HIDDEN'},
108 use_selection: BoolProperty(
109 name="Selection Only",
110 description="Export selected objects only",
111 default=False,
114 def execute(self, context):
115 from . import export_3ds
117 keywords = self.as_keywords(ignore=("axis_forward",
118 "axis_up",
119 "filter_glob",
120 "check_existing",
122 global_matrix = axis_conversion(to_forward=self.axis_forward,
123 to_up=self.axis_up,
124 ).to_4x4()
125 keywords["global_matrix"] = global_matrix
127 return export_3ds.save(self, context, **keywords)
130 # Add to a menu
131 def menu_func_export(self, context):
132 self.layout.operator(Export3DS.bl_idname, text="3D Studio (.3ds)")
135 def menu_func_import(self, context):
136 self.layout.operator(Import3DS.bl_idname, text="3D Studio (.3ds)")
139 def register():
140 bpy.utils.register_class(Import3DS)
141 bpy.utils.register_class(Export3DS)
143 bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
144 bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
147 def unregister():
148 bpy.utils.unregister_class(Import3DS)
149 bpy.utils.unregister_class(Export3DS)
151 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
152 bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
154 # NOTES:
155 # why add 1 extra vertex? and remove it when done? -
156 # "Answer - eekadoodle - would need to re-order UV's without this since face
157 # order isnt always what we give blender, BMesh will solve :D"
159 # disabled scaling to size, this requires exposing bb (easy) and understanding
160 # how it works (needs some time)
163 if __name__ == "__main__":
164 register()