Skip to content

Commit

Permalink
Potential fix for exporting with NoneType node_tree.nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
loonaticx committed Apr 29, 2021
1 parent e44c5cf commit b27b15b
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions yabee_libs/egg_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,27 +1181,28 @@ def get_egg_materials_str(object_names=None):
elif nodeTree.links[0].to_node.name == 'Material Output':
print("INFO: {} is using for!".format(nodeTree.links[0].to_node.name)),
objects = bpy.context.selected_objects
for node in bpy.data.materials[0].node_tree.nodes:
if node.name == "Principled BSDF":
principled_bsdf = node
basecol = list(principled_bsdf.inputs["Base Color"].default_value)
metallic = principled_bsdf.inputs["Metallic"].default_value
roughness = principled_bsdf.inputs["Roughness"].default_value

base_r = basecol[0]
base_g = basecol[1]
base_b = basecol[2]
base_a = basecol[3]

mat_str += ' <Scalar> baser { %s }\n' % STRF(base_r)
mat_str += ' <Scalar> baseg { %s }\n' % STRF(base_g)
mat_str += ' <Scalar> baseb { %s }\n' % STRF(base_b)
mat_str += ' <Scalar> basea { %s }\n' % STRF(base_a)

# ("DEFAULT", "EMISSIVE", "CLEARCOAT", "TRANSPARENT","SKIN", "FOLIAGE")
mat_str += ' <Scalar> roughness { %s }\n' % STRF(roughness)
mat_str += ' <Scalar> metallic { %s }\n' % STRF(metallic)
mat_str += ' <Scalar> local { %s }\n' % STRF(0.0)
if bpy.data.materials[0].node_tree is not None:
for node in bpy.data.materials[0].node_tree.nodes:
if node.name == "Principled BSDF":
principled_bsdf = node
basecol = list(principled_bsdf.inputs["Base Color"].default_value)
metallic = principled_bsdf.inputs["Metallic"].default_value
roughness = principled_bsdf.inputs["Roughness"].default_value

base_r = basecol[0]
base_g = basecol[1]
base_b = basecol[2]
base_a = basecol[3]

mat_str += ' <Scalar> baser { %s }\n' % STRF(base_r)
mat_str += ' <Scalar> baseg { %s }\n' % STRF(base_g)
mat_str += ' <Scalar> baseb { %s }\n' % STRF(base_b)
mat_str += ' <Scalar> basea { %s }\n' % STRF(base_a)

# ("DEFAULT", "EMISSIVE", "CLEARCOAT", "TRANSPARENT","SKIN", "FOLIAGE")
mat_str += ' <Scalar> roughness { %s }\n' % STRF(roughness)
mat_str += ' <Scalar> metallic { %s }\n' % STRF(metallic)
mat_str += ' <Scalar> local { %s }\n' % STRF(0.0)

if matIsFancyPBRNode is False:
print("INFO: Non-Shader Mode is using for!")
Expand Down

0 comments on commit b27b15b

Please sign in to comment.