glTF exporter: option to export placeholder of materials
* export all materials used by object exported * not export materials at all (mesh will be exported as a single primitive) * export placeholder: materials are not exported, but slots are still used to separate mesh into primitives
This commit is contained in:
parent
9db2451888
commit
6541699694
|
@ -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')
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue