Created
November 26, 2018 17:49
-
-
Save furby-tm/76ad16abe731e534eab50c27fcaae05a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _AiNode(node, prefix, nodes, mat): | |
""" | |
Args: | |
node (ArnoldNode): node. | |
prefix (str): node name prefix. | |
nodes (dict): created nodes {Node: AiNode}. | |
Returns: | |
arnold.AiNode or None | |
""" | |
if not isinstance(node, ArnoldNode): | |
return None | |
anode = nodes.get(node) | |
if anode is None: | |
anode = arnold.AiNode(node.ai_name) | |
name = "%s&N%d::%s" % (prefix, len(nodes), _RN.sub("_", node.name)) | |
arnold.AiNodeSetStr(anode, "name", name) | |
nodes[node] = anode | |
for n in mat.node_tree.links: | |
# if input.is_linked: | |
_anode = _AiNode(n.from_node, prefix, nodes, mat) | |
if _anode is not None: | |
arnold.AiNodeLink(_anode, n.from_socket.name, anode) | |
continue | |
if not n.hide_value: | |
_AiNodeSet[n.bl_idname](anode, n.from_socket.name, n.default_value) | |
for p_name, (p_type, p_value) in node.ai_properties.items(): | |
_AiNodeSet[p_type](anode, p_name, p_value) | |
return anode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment