diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2020-09-17 22:46:22 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2020-09-17 22:46:22 +0300 |
commit | 654169969408144f472dd752beec233d1368af8f (patch) | |
tree | 6d27e20cf87b09442d64e5e7b9db9748ea8c4807 /io_scene_gltf2/blender | |
parent | 9db2451888a5f5a67d3d3d0fc2a967c208a3a801 (diff) |
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
Diffstat (limited to 'io_scene_gltf2/blender')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_extract.py | 2 | ||||
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py index 5b9e68f5..c0311b98 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 4fe498e1..fd325d48 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( |