Beispiel #1
0
def add_temporal_stethoscope(nodes, links, existing_node):
    """Add Temporal Stethoscope and connects it to existing node"""
    bl_idname_new_node = 'SvStethoscopeNodeMK2'
    try:
        new_node = nodes['Temporal Stethoscope']

    except KeyError:
        new_node = nodes.new(bl_idname_new_node)
        new_node.name = 'Temporal Stethoscope'
        new_node.label = 'Temporal Stethoscope'
        new_node.color = (0.336045, 0.336045, 0.666654)

    # else the location is compounded, iterately
    new_node.parent = None
    new_node.location = (0, 0)

    offset_node_location(existing_node, new_node, [30, -200])
    frame_adjust(existing_node, new_node)

    outputs = existing_node.outputs
    inputs = new_node.inputs
    connected_to = 0
    # find if the node was already connected to it and in that case use next socket
    for i, socket in enumerate(outputs):
        if inputs[0].other == socket:
            connected_to = i + 1
            break

    for i in range(len(outputs)):
        socket = outputs[(i + connected_to) % len(outputs)]
        if socket.hide:
            continue
        links.new(socket, inputs[0])
        break
def add_connection(tree, bl_idname_new_node, offset):

    nodes = tree.nodes
    links = tree.links

    output_map = get_verts_edge_poly_output_sockets(nodes.active)

    existing_node = nodes.active

    if isinstance(bl_idname_new_node, str):
        # single new node..

        new_node = nodes.new(bl_idname_new_node)
        offset_node_location(existing_node, new_node, offset)
        frame_adjust(existing_node, new_node)

        outputs = existing_node.outputs
        inputs = new_node.inputs

        # first scenario not handelled in b28 yet.
        if existing_node.bl_idname in supported_mesh_viewers and bl_idname_new_node == 'IndexViewerNode':
            new_node.draw_bg = True
            connect_idx_viewer(tree, existing_node, new_node)

        elif bl_idname_new_node == 'SvStethoscopeNodeMK2':
            # we can't determin thru cursor location which socket was nearest the rightclick
            # maybe in the future.. or if someone does know :)
            for socket in outputs:
                if socket.hide:
                    continue
                # connect_stethoscope to first visible output socket of active node
                links.new(socket, inputs[0])
                break

            tree.update(
            )  # without this the node won't show output until an update is triggered manually
            # existing_node.process_node(None)

        elif bl_idname_new_node == 'SvVDExperimental':
            previous_state = tree.sv_process
            tree.sv_process = False
            if 'verts' in output_map:
                links.new(outputs[output_map['verts']], inputs[0])
                if 'faces' in output_map:
                    links.new(outputs[output_map['faces']], inputs[2])
                if 'edges' in output_map:
                    links.new(outputs[output_map['edges']], inputs[1])

            tree.sv_process = previous_state
            tree.update()
            # existing_node.process_node(None)

        else:
            ...
    elif isinstance(bl_idname_new_node, list):
        # maybe vdmk2 + indexviewer
        ...
Beispiel #3
0
    def execute(self, context):

        node = context.node
        tree = node.id_data
        new_node = tree.nodes.new('SvLoopOutNode')
        new_node.parent = None
        new_node.location = (node.location.x + node.width + 400, node.location.y)
        tree.links.new(node.outputs[0], new_node.inputs[0])
        frame_adjust(node, new_node)
        return {'FINISHED'}
Beispiel #4
0
def add_connection(tree, bl_idname_new_node, offset):

    nodes = tree.nodes
    links = tree.links

    output_map = get_verts_edge_poly_output_sockets(nodes.active)

    existing_node = nodes.active

    if isinstance(bl_idname_new_node, str):
        # single new node..

        new_node = nodes.new(bl_idname_new_node)
        offset_node_location(existing_node, new_node, offset)
        frame_adjust(existing_node, new_node)

        outputs = existing_node.outputs
        inputs = new_node.inputs

        if existing_node.bl_idname in supported_mesh_viewers and bl_idname_new_node == 'IndexViewerNode':
            new_node.draw_bg = True
            connect_idx_viewer(tree, existing_node, new_node)

        elif bl_idname_new_node == 'SvStethoscopeNodeMK2':
            # we can't determin thru cursor location which socket was nearest the rightclick
            # maybe in the future.. or if someone does know :)
            for socket in outputs:
                if socket.hide:
                    continue
                # connect_stethoscope to first visible output socket of active node
                links.new(socket, inputs[0])
                break

        elif bl_idname_new_node == 'ViewerNode2':

            if 'verts' in output_map:
                if 'faces' in output_map:
                    links.new(outputs[output_map['verts']], inputs[0])
                    links.new(outputs[output_map['faces']], inputs[1])
                elif 'edges' in output_map:
                    links.new(outputs[output_map['verts']], inputs[0])
                    links.new(outputs[output_map['edges']], inputs[1])

        else:
            ...
    elif isinstance(bl_idname_new_node, list):
        # maybe vdmk2 + indexviewer
        ...
def add_connection(tree, bl_idname_new_node, offset):

    nodes = tree.nodes
    links = tree.links

    output_map = get_verts_edge_poly_output_sockets(nodes.active)

    existing_node = nodes.active

    if isinstance(bl_idname_new_node, str):
        # single new node..

        new_node = nodes.new(bl_idname_new_node)
        offset_node_location(existing_node, new_node, offset)
        frame_adjust(existing_node, new_node)

        outputs = existing_node.outputs
        inputs = new_node.inputs

        if existing_node.bl_idname in supported_mesh_viewers and bl_idname_new_node == 'IndexViewerNode':
            new_node.draw_bg = True
            connect_idx_viewer(tree, existing_node, new_node)

        elif bl_idname_new_node == 'SvStethoscopeNodeMK2':
            # we can't determin thru cursor location which socket was nearest the rightclick
            # maybe in the future.. or if someone does know :)
            for socket in outputs:
                if socket.hide:
                    continue
                # connect_stethoscope to first visible output socket of active node
                links.new(socket, inputs[0])
                break

        elif bl_idname_new_node == 'ViewerNode2':

            if 'verts' in output_map:
                if 'faces' in output_map:
                    links.new(outputs[output_map['verts']], inputs[0])
                    links.new(outputs[output_map['faces']], inputs[1])
                elif 'edges' in output_map:
                    links.new(outputs[output_map['verts']], inputs[0])
                    links.new(outputs[output_map['edges']], inputs[1])

        else:
            ...
    elif isinstance(bl_idname_new_node, list):
        # maybe vdmk2 + indexviewer
        ...
Beispiel #6
0
def add_temporal_viewer_draw(tree, nodes, links, existing_node, cut_links):
    tree = nodes[0].id_data
    previous_state = tree.sv_process
    tree.sv_process = False
    bl_idname_new_node = 'SvViewerDrawMk4'
    output_map = get_output_sockets_map(existing_node)
    try:
        new_node = nodes['Temporal Viewer']
        if cut_links or ('verts' in output_map and 'faces' in output_map):
            for i in range(4):
                for link in new_node.inputs[i].links:
                    links.remove(link)

    except KeyError:
        new_node = nodes.new(bl_idname_new_node)
        new_node.name = 'Temporal Viewer'
        new_node.label = 'Temporal Viewer'
        new_node.color = (0.666141, 0.203022, 0)

    # else the location is compounded, iterately
    new_node.parent = None
    new_node.location = (0, 0)

    offset_node_location(existing_node, new_node, [100, 250])
    frame_adjust(existing_node, new_node)

    outputs = existing_node.outputs
    inputs = new_node.inputs
    if 'verts' in output_map:
        links.new(outputs[output_map['verts']], inputs[0])
        if 'faces' in output_map:
            links.new(outputs[output_map['faces']], inputs[2])
        if 'edges' in output_map:
            links.new(outputs[output_map['edges']], inputs[1])
    else:
        for socket in outputs:
            if socket.bl_idname == "SvVerticesSocket":
                links.new(socket, inputs[0])
                break
            if socket.bl_idname == "SvMatrixSocket":
                links.new(socket, inputs[3])
                break
    tree.sv_process = previous_state
    tree.update()
Beispiel #7
0
def view_node(tree):
    '''viewer map is a node attribute to inform to the operator how to visualize
    the node data
    it is a list with two items.
    The first item is a list with tuples, every tuple need to have the node bl_idanme and offset to the previous node
    The second item is a list with tuples, every tuple indicates a link.
    The link is defined by two pairs of numbers, refering to output and input
    The first number of every pair indicates the node being 0 the active node 1 the first needed node and so on
    The second nmber of every pair indicates de socket index.

    So to say: create a Viewer Draw with a offset of 60,0 and connect the first output to the vertices input
    the node would need to have this:

        viewer_map = [
            ("SvViewerDrawMk4", [60, 0])
            ], [
            ([0, 0], [1, 0])
            ]

    '''
    nodes = tree.nodes
    links = tree.links
    existing_node = nodes.active
    node_list = [existing_node]
    output_map = existing_node.viewer_map

    previous_state = tree.sv_process
    tree.sv_process = False

    for node in output_map[0]:
        bl_idname_new_node, offset = node
        new_node = nodes.new(bl_idname_new_node)
        apply_default_preset(new_node)
        offset_node_location(node_list[-1], new_node, offset)
        frame_adjust(node_list[-1], new_node)
        node_list.append(new_node)
    for link in output_map[1]:
        output_s, input_s = link
        links.new(node_list[output_s[0]].outputs[output_s[1]],
                  node_list[input_s[0]].inputs[input_s[1]])
    tree.sv_process = previous_state
    tree.update()
def add_temporal_viewer_draw(tree, nodes, links, existing_node, cut_links):
    bl_idname_new_node = 'SvVDExperimental'
    output_map = get_verts_edge_poly_output_sockets(existing_node)
    try:
        new_node = nodes['Temporal Viewer']
        if cut_links or ('verts' in output_map and 'faces' in output_map):
            for i in range(4):
                for link in new_node.inputs[i].links:
                    links.remove(link)

    except KeyError:
        new_node = nodes.new(bl_idname_new_node)
        new_node.name = 'Temporal Viewer'
        new_node.label = 'Temporal Viewer'
        new_node.color = (0.666141, 0.203022, 0)

    offset_node_location(existing_node, new_node, [100, 250])
    frame_adjust(existing_node, new_node)

    outputs = existing_node.outputs
    inputs = new_node.inputs
    if 'verts' in output_map:
        links.new(outputs[output_map['verts']], inputs[0])
        if 'faces' in output_map:
            links.new(outputs[output_map['faces']], inputs[2])
        if 'edges' in output_map:
            links.new(outputs[output_map['edges']], inputs[1])
    else:
        for socket in outputs:
            if socket.bl_idname == "SvVerticesSocket":
                links.new(socket, inputs[0])
                break
            if socket.bl_idname == "SvMatrixSocket":
                links.new(socket, inputs[3])
                break
    tree.update()
Beispiel #9
0
def add_connection(tree, bl_idname_new_node, offset):

    nodes = tree.nodes
    links = tree.links

    output_map = get_output_sockets_map(nodes.active)

    existing_node = nodes.active

    if isinstance(bl_idname_new_node, str):
        # single new node..

        new_node = nodes.new(bl_idname_new_node)
        apply_default_preset(new_node)
        offset_node_location(existing_node, new_node, offset)
        frame_adjust(existing_node, new_node)

        outputs = existing_node.outputs
        inputs = new_node.inputs

        if existing_node.bl_idname in supported_mesh_viewers and bl_idname_new_node == 'SvIDXViewer28':
            new_node.draw_bg = True
            connect_idx_viewer(tree, existing_node, new_node)

        elif bl_idname_new_node == 'SvStethoscopeNodeMK2':
            # we can't determin thru cursor location which socket was nearest the rightclick
            # maybe in the future.. or if someone does know :)
            for socket in outputs:
                if socket.hide:
                    continue
                # connect_stethoscope to first visible output socket of active node
                links.new(socket, inputs[0])
                break

            tree.update(
            )  # without this the node won't show output until an update is triggered manually
            # existing_node.process_node(None)

        elif bl_idname_new_node == 'SvViewerDrawMk4':
            previous_state = tree.sv_process
            tree.sv_process = False
            if 'verts' in output_map:
                links.new(outputs[output_map['verts']], inputs[0])
                if 'faces' in output_map:
                    links.new(outputs[output_map['faces']], inputs[2])
                if 'edges' in output_map:
                    links.new(outputs[output_map['edges']], inputs[1])
            elif 'curve' in output_map:

                eval_node = nodes.new('SvExEvalCurveNode')
                apply_default_preset(eval_node)
                offset_node_location(existing_node, eval_node, offset)
                frame_adjust(existing_node, eval_node)
                offset_node_location(eval_node, new_node, offset)
                frame_adjust(eval_node, new_node)
                links.new(outputs[output_map['curve']], eval_node.inputs[0])
                links.new(eval_node.outputs[0], inputs[0])
                links.new(eval_node.outputs[1], inputs[1])

            elif 'surface' in output_map:
                eval_node = nodes.new('SvExEvalSurfaceNode')
                apply_default_preset(eval_node)
                offset_node_location(existing_node, eval_node, offset)
                frame_adjust(existing_node, eval_node)
                offset_node_location(eval_node, new_node, offset)
                frame_adjust(eval_node, new_node)
                links.new(outputs[output_map['surface']], eval_node.inputs[0])
                links.new(eval_node.outputs[0], inputs[0])
                links.new(eval_node.outputs[1], inputs[1])
                links.new(eval_node.outputs[2], inputs[2])
            elif 'solid' in output_map:
                tree.nodes.remove(new_node)
                new_node = nodes.new('SvSolidViewerNode')
                apply_default_preset(new_node)
                offset_node_location(existing_node, new_node, offset)
                frame_adjust(existing_node, new_node)
                links.new(outputs[output_map['solid']], new_node.inputs[0])
            tree.sv_process = previous_state
            tree.update()
            # existing_node.process_node(None)

        else:
            ...
    elif isinstance(bl_idname_new_node, list):
        # maybe vdmk2 + indexviewer
        ...