Proper node positioning after import

This commit is contained in:
khreathor 2019-01-10 20:56:40 +01:00 committed by Bill Currie
parent a13c382969
commit 4f29f57e77

View file

@ -131,11 +131,20 @@ def setup_skins(mdl, uvs):
shaderOut = mat.node_tree.nodes["Material Output"]
mat.node_tree.nodes.remove(mat.node_tree.nodes["Principled BSDF"])
emissionNode.location = (0, 0)
shaderOut.location = (200, 0)
yPos = 0
for j, subskin in enumerate(skin.skins):
tex_node = mat.node_tree.nodes.new("ShaderNodeTexImage")
tex_node.image = mdl.images[img_counter]
img_counter += 1
tex_node.interpolation = "Closest"
tex_node.location = (-300, yPos)
yPos -= 280
if j == 0:
# connect only first texture (we'll need something smarter in the future)
mat.node_tree.links.new(tex_node.outputs[0], emissionNode.inputs[0])
@ -156,6 +165,10 @@ def setup_skins(mdl, uvs):
img_counter += 1
tex_node.interpolation = "Closest"
emissionNode.location = (0, 0)
shaderOut.location = (200, 0)
tex_node.location = (-300, 0)
mat.node_tree.links.new(tex_node.outputs[0], emissionNode.inputs[0])
mat.node_tree.links.new(emissionNode.outputs[0], shaderOut.inputs[0])
mdl.mesh.materials.append(mat)