diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 8eaf5e8d727f2dcd38a2810d201f436d50f0aa70..3e09c58fd98d6459f8b7099d777a4e5af93a7b71 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin SchmithĂĽsen, Jim Eckerlein, and many external contributors', - "version": (1, 4, 29), + "version": (1, 4, 30), 'blender': (2, 90, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', @@ -214,10 +214,16 @@ class ExportGLTF2_Base: default=False ) - export_materials: BoolProperty( + export_materials: EnumProperty( name='Materials', - description='Export materials', - default=True + items=(('EXPORT', 'Export', + 'Export all materials used by included objects'), + ('PLACEHOLDER', 'Placeholder', + 'Do not export materials, but write multiple primitive groups per mesh, keeping material slot information'), + ('NONE', 'No export', + 'Do not export materials, and combine mesh primitive groups, losing material slot information')), + description='Export materials ', + default='EXPORT' ) export_colors: BoolProperty( @@ -672,7 +678,7 @@ class GLTF_PT_export_geometry(bpy.types.Panel): layout.prop(operator, 'export_colors') layout.prop(operator, 'export_materials') col = layout.column() - col.active = operator.export_materials + col.active = operator.export_materials == "EXPORT" col.prop(operator, 'export_image_format') diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py index 5b9e68f51775ea136bba16e8ca3823eabedf9ed8..c0311b986abdcf5117ff21436412f76df1f66fdd 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py @@ -179,7 +179,7 @@ def extract_primitives(glTF, blender_mesh, library, blender_object, blender_vert prim_indices = {} # maps material index to TRIANGLES-style indices into dots - if not use_materials: + if use_materials == "NONE": # Only for None. For placeholder and export, keep primitives # Put all vertices into one primitive prim_indices[-1] = loop_indices diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py index 4fe498e10d26f59adaa2762c75e31ff715729c0a..fd325d489f3cbe3ed52b4d588429b0f43a101ef0 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py @@ -54,15 +54,17 @@ def gather_primitives( material_idx = internal_primitive['material'] double_sided = False material = None - try: - blender_material = bpy.data.materials[material_names[material_idx]] - double_sided = not blender_material.use_backface_culling - material = gltf2_blender_gather_materials.gather_material(blender_material, - double_sided, - export_settings) - except IndexError: - # no material at that index - pass + + if export_settings['gltf_materials'] == "EXPORT": + try: + blender_material = bpy.data.materials[material_names[material_idx]] + double_sided = not blender_material.use_backface_culling + material = gltf2_blender_gather_materials.gather_material(blender_material, + double_sided, + export_settings) + except IndexError: + # no material at that index + pass primitive = gltf2_io.MeshPrimitive(