Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def withNodes(self, mat):
- with_nodes = False
- outNodeName = self.getNodeOutName(mat)
- linked_node = None
- # temporary fix for blend mat issue( excluding to possible replacement)
- validReplaceNodes = ['shinydiffusemat', 'glossy', 'glass', 'translucent']
- # Checking: if there is nodetree, if it contains a nodeout and if it is linked
- if mat.bounty.nodetree != "" and outNodeName is not 'None':
- ntree = bpy.data.node_groups[mat.bounty.nodetree]
- inputNodeOut = ntree.nodes[outNodeName].inputs['Surface']
- # check nodetree
- if inputNodeOut.is_linked:
- if inputNodeOut.links[0].from_node.bl_label == 'blend':
- nodelink = inputNodeOut.links[0].from_node
- # one
- mat1 = bpy.data.materials[nodelink.BlendOne]
- if mat1 not in self.materialMap:
- self.writeMaterial(mat1)
- print('blend value: ', nodelink.blend_amount)
- #mat.bounty.blend_value = nodelink.blend_amount
- # two
- mat2 = bpy.data.materials[nodelink.BlendTwo]
- if mat2 not in self.materialMap:
- self.writeMaterial(mat2)
- with_nodes= True
- # check a valid node type solo se usa cuando el nodo out no esta conectado
- # a un nodo valido
- if inputNodeOut.links[0].from_node.bl_label not in validMaterialTypes:
- ntree.links.remove(inputNodeOut.links[0])
- # Trying to connect a valid node among those that compose the node tree
- linked = False
- for n in ntree.nodes:
- if n.bl_label in validReplaceNodes:
- ntree.links.new(inputNodeOut, n.outputs[0])
- linked = True
- break
- # If no nodes are supported, one is created
- if not linked:
- n = ntree.nodes.new("ShinyDiffuseShaderNode")
- n.location = [-200, 0]
- ntree.links.new(inputNodeOut, n.outputs[0])
- #
- with_nodes= True
- self.yi.printWarning('An invalid node has been connected. Changing to a valid one')
- #
- linked_node = inputNodeOut.links[0].from_node
- mat.bounty.mat_type = linked_node.bl_label
- #
- return with_nodes, linked_node
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement