Skip to content

Commit

Permalink
Add gltf setup progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Naxela committed May 21, 2023
1 parent 76e32b4 commit f97ee22
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 18 deletions.
55 changes: 37 additions & 18 deletions addon/operators/tlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1966,28 +1966,47 @@ def execute(self, context):

scene = context.scene
cycles = scene.cycles
material = bpy.context.active_object.active_material

nodes = material.node_tree.nodes
# create group data
gltf_settings = bpy.data.node_groups.get('glTF Settings')
if gltf_settings is None:
bpy.data.node_groups.new('glTF Settings', 'ShaderNodeTree')

# add group to node tree
gltf_settings_node = nodes.get('glTF Settings')
if gltf_settings_node is None:
gltf_settings_node = nodes.new('ShaderNodeGroup')
gltf_settings_node.name = 'glTF Settings'
gltf_settings_node.node_tree = bpy.data.node_groups['glTF Settings']
for obj in bpy.context.scene.objects:

# create group inputs
if gltf_settings_node.inputs.get('Occlusion') is None:
gltf_settings_node.inputs.new('NodeSocketFloat','Occlusion')
print("Iterating: " + obj.name)

#return gltf_settings_node
if obj.type == 'MESH' and obj.name in bpy.context.view_layer.objects:
if obj.TLM_ObjectProperties.tlm_mesh_lightmap_use:

return {'FINISHED'}
for slot in obj.material_slots:

material = slot.material

nodes = material.node_tree.nodes
# create group data
gltf_settings = bpy.data.node_groups.get('glTF Settings')
if gltf_settings is None:
bpy.data.node_groups.new('glTF Settings', 'ShaderNodeTree')

# add group to node tree
gltf_settings_node = nodes.get('glTF Settings')
if gltf_settings_node is None:
gltf_settings_node = nodes.new('ShaderNodeGroup')
gltf_settings_node.name = 'glTF Settings'
gltf_settings_node.node_tree = bpy.data.node_groups['glTF Settings']

# create group inputs
if gltf_settings_node.inputs.get('Occlusion') is None:
gltf_settings_node.inputs.new('NodeSocketFloat','Occlusion')

gltf_settings_node.location.y = 400

lightmapNode = nodes.get("TLM_Lightmap")
#mainNode = nodes.get()

material.node_tree.links.remove(lightmapNode.outputs[0].links[0])
material.node_tree.links.new(lightmapNode.outputs[0], gltf_settings_node.inputs[0])
#TLM_Lightmap

#return gltf_settings_node

return {'FINISHED'}

class TLM_ShiftMultiplyLinks(bpy.types.Operator):
bl_idname = "tlm.shift_multiply_links"
Expand Down
2 changes: 2 additions & 0 deletions addon/panels/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@ def draw(self, context):
row.operator("tlm.add_gltf_node")
row = layout.row()
row.operator("tlm.shift_multiply_links")
row = layout.row()
row.prop(sceneProperties, "tlm_gltf_iterate_all")

class TLM_PT_Selection(bpy.types.Panel):
bl_label = "Selection"
Expand Down
5 changes: 5 additions & 0 deletions addon/properties/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ class TLM_SceneProperties(bpy.types.PropertyGroup):
name="Invert direction",
description="Inverts the direction.",
default=False)

tlm_gltf_iterate_all : BoolProperty(
name="Apply to all materials",
description="Applies the GLTF node setup to all materials in the scene.",
default=False)

tlm_environment_probe_resolution : EnumProperty(
items = [('32', '32', 'TODO'),
Expand Down

0 comments on commit f97ee22

Please sign in to comment.