Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2022-07-07 09:03:39 +0300
committerJulien Duroure <julien.duroure@gmail.com>2022-07-07 09:03:39 +0300
commit042fbefac686666190915d206600a5dab8e03066 (patch)
tree52bb07b361d72b14b98275a07418f7d72489b5bf /io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
parent09d752e8453415daff11e94f87d8692a04b4eeff (diff)
glTF importer/exporter: Manage some official Khronos Extensions about Materials
KHR_materials_ior KHR_materials_sheen KHR_materials_specular KHR_materials_transmission KHR_materials_variants KHR_materials_emissive_strength KHR_materials_volume Documentation update is still in progress
Diffstat (limited to 'io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py')
-rw-r--r--io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
index 0377a6b7..36772667 100644
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_tree.py
@@ -468,3 +468,20 @@ class VExportTree:
skin = gather_skin(n.uuid, self.export_settings)
skins.append(skin)
return skins
+
+ def variants_reset_to_original(self):
+ # Only if Variants are displayed and exported
+ if bpy.context.preferences.addons['io_scene_gltf2'].preferences.KHR_materials_variants_ui is False:
+ return
+ objects = [self.nodes[o].blender_object for o in self.get_all_node_of_type(VExportNode.OBJECT) if self.nodes[o].blender_object.type == "MESH" \
+ and self.nodes[o].blender_object.data.get('gltf2_variant_default_materials') is not None]
+ for obj in objects:
+ # loop on material slots ( primitives )
+ for mat_slot_idx, s in enumerate(obj.material_slots):
+ # Check if there is a default material for this slot
+ for i in obj.data.gltf2_variant_default_materials:
+ if i.material_slot_index == mat_slot_idx:
+ s.material = i.default_material
+ break
+
+ # If not found, keep current material as default