示例#1
0
    def importLmtl(self):
        pos = NodegraphAPI.GetViewPortPosition(NodegraphAPI.GetRootNode())
        currentItemName = str(self.listWidget.currentItem().text())
        checkCat = str(self.catedoryCB.currentText())

        if not checkCat == 'ALL':
            klfName = os.path.join(self.directory, checkCat,
                                   currentItemName + '.klf')
            expression = 'path.join(getenv("MATLIB",0), "material_library", "{}", "{}")'.format(
                checkCat, currentItemName + '.klf')
        else:
            klfName = os.path.join(
                str(self.listWidget.currentItem().data(
                    QtCore.Qt.UserRole).toPyObject()),
                currentItemName + '.klf')
            expression= 'path.join(getenv("MATLIB",0), "material_library", "{}", "{}")'\
                .format(str(self.listWidget.currentItem().data(QtCore.Qt.UserRole).toPyObject()).split(os.sep)[-1], currentItemName+'.klf')

        if os.path.exists(klfName):
            materialNode = NodegraphAPI.CreateNode('Material',
                                                   NodegraphAPI.GetRootNode())
            materialNode.getParameter('name').setValue(currentItemName, 0)
            DrawingModule.SetCustomNodeColor(materialNode, 0.2, 0.27, 0.4)
            materialNode.getParameter('action').setValue(
                'create from Look File', 0)
            materialNode.getParameter('lookfile.lookfile').setExpression(
                expression)
            NodegraphAPI.SetNodePosition(materialNode,
                                         ((pos[0][0]), pos[0][1]))

            materialAssign = NodegraphAPI.CreateNode(
                'MaterialAssign', NodegraphAPI.GetRootNode())
            materialAssign.setName('MA_' + currentItemName)
            materialAssign.getParameter(
                'args.materialAssign.value').setExpression(
                    "scenegraphLocationFromNode(getNode('{}'))".format(
                        materialNode.getName()))
            DrawingModule.SetCustomNodeColor(materialAssign, 0.2, 0.27, 0.4)
            NodegraphAPI.SetNodePosition(materialAssign,
                                         ((pos[0][0]), pos[0][1] - 50))
            materialNode.getOutputPort('out').connect(
                materialAssign.getInputPort('input'))
            NodegraphAPI.SetNodeEdited(materialAssign,
                                       edited=True,
                                       exclusive=True)

        else:
            QtGui.QMessageBox.information(
                None, currentItemName,
                'There in no Look File for {}, try importing Material!'.format(
                    currentItemName))
示例#2
0
def create_node():
    '''
    :description to create lookdev bake node
    :param None
    :example
        from resources.studio_nodes.lookdev_bake_node import node
        node.create_node()  
    '''       
    parent = NodegraphAPI.GetRootNode()
    knode = NodegraphAPI.CreateNode('LookFileBake', parent=parent)
    knode.setName(studio_nodes.LOOKDEV_BAKE_NODE_TYPE)    
    add_parameters(knode)    
    NodegraphAPI.SetNodeViewed(knode, True, exclusive=True)
    NodegraphAPI.SetNodeEdited(knode, True, exclusive=True)  
示例#3
0
    def qitem_edit_ktnnode(self, qitem):
        """ Put the katana node linked to the given qitem in edit mode

        Args:
            qitem(QtWidgets.QTreeWidgetItem):

        Returns:
            Katana Node edited
        """
        ktn_node = qitem.data(TREEW_DATA["katana_node"]["column"],
                              QtCore.Qt.UserRole)
        NodegraphAPI.SetNodeEdited(ktn_node, edited=True,
                                   exclusive=True)  # edit only the given node
        return ktn_node
示例#4
0
def create_node():
    '''
    :description to create generic asset node
    :param None
    :example
        from resources.studio_nodes.generic_asset_node import node
        node.create_node()  
    '''
    parent = NodegraphAPI.GetRootNode()
    knode = NodegraphAPI.CreateNode('Group', parent=parent)
    knode.setName(studio_nodes.GENERIC_ASSET_NODE_TYPE)
    add_parameters(knode)
    NodegraphAPI.SetNodeViewed(knode, True, exclusive=True)
    NodegraphAPI.SetNodeEdited(knode, True, exclusive=True)
示例#5
0
def create_node():
    '''
    :description to create lighting asset node
    :param None
    :example
        from resources.studio_nodes.lighting_asset_node import node
        node.create_node()  
    '''
    parent = NodegraphAPI.GetRootNode()
    knode = NodegraphAPI.CreateNode('Group', parent=parent)
    knode.setName(studio_nodes.LIGHTING_ASSET_NODE_TYPE)
    knode.addOutputPort('out')
    add_parameters(knode)
    NodegraphAPI.SetNodeViewed(knode, True, exclusive=True)
    NodegraphAPI.SetNodeEdited(knode, True, exclusive=True)
def ActionCallback(value):
    """
    Callback for the layered menu, which creates a PrmanShadingNode node and
    sets its B{nodeType} parameter to the given C{value}, which is the name of
    a PRMan shader as set for the menu entry in L{PopulateCallback()}.

    @type value: C{str}
    @rtype: C{object}
    @param value: An arbitrary object that the menu entry that was chosen
        represents. In our case here, this is the name of a PRMan shader as
        passed to the L{LayeredMenuAPI.LayeredMenu.addEntry()} function in
        L{PopulateCallback()}.
    @return: An arbitrary object. In our case here, we return the created
        PrmanShadingNode node, which is then placed in the B{Node Graph} tab
        because it is a L{NodegraphAPI.Node} instance.
    """
    # Create the node, set its shader, and set the name with the shader name
    node = NodegraphAPI.CreateNode('ArnoldShadingNode')

    node.getParameter('nodeType').setValue(value, 0)
    node.setName(value)
    node.getParameter('name').setValue(node.getName(), 0)
    NodegraphAPI.SetNodeEdited(node, True, True)
    return node
示例#7
0
def createKatanaNodes(fileOut = '/tmp/fileDispFromLua.txt'):
    # check if there is a node ('Attribute_Disp') existing if yes delete it
    # existingNode = NodegraphAPI.GetNode('Attribute_Disp')
    # if existingNode :
    #     inputNodePort = existingNode.getInputPortByIndex(0)
    #     outputNodePort = existingNode.getOutputPortByIndex(0)
    #     inputNodePort.connect(outputNodePort)
    #     existingNode.delete()
    inputFile = open(fileOut,'a')
    node = NodegraphAPI.GetAllSelectedNodes()[0] # select the node
    nodePos = NodegraphAPI.GetNodePosition(node) # get the position of node
    nodeOutPort = node.getOutputPortByIndex(0) # get the output port
    nextPort = nodeOutPort.getConnectedPorts()[0] # get the first connected port from the previous node

    # create the opscript node
    root = NodegraphAPI.GetRootNode()
    opscriptFindDisp = NodegraphAPI.CreateNode('OpScript',root)
    opscriptFindDisp.setName('findDisp')
    opscriptFindDisp.getParameter('CEL').setValue('/root/world//*{hasattr("materialOverride.parameters.dsp_map")}',0)
    opscriptFindDispUserParam = opscriptFindDisp.getParameters().createChildGroup('user')
    opscriptFindDispUserParamFileOut = opscriptFindDispUserParam.createChildString('fileOut',fileOut)
    opscriptFindDisp.getParameter('script.lua').setValue("local getdispMap = require 'dispFunc'\ngetdispMap.getDispMap()",0)
    opscriptFindDispInPort = opscriptFindDisp.getInputPort('i0')
    opscriptFindDispOutPort = opscriptFindDisp.getOutputPort('out')
    nodeOutPort.connect(opscriptFindDispInPort)
    opscriptFindDispOutPort.connect(nextPort)
    NodegraphAPI.SetNodePosition(opscriptFindDisp, (nodePos[0]+50,nodePos[1]-50))
    opscriptFindDispPos = NodegraphAPI.GetNodePosition(opscriptFindDisp)
    # set the view and the edit on the opscript node
    NodegraphAPI.SetNodeViewed(opscriptFindDisp, True, exclusive=True)
    NodegraphAPI.SetNodeEdited(opscriptFindDisp, True, exclusive=True)

    # dummy functions to run the opscript and create the file
    sg = ScenegraphManager.getActiveScenegraph()
    node = NodegraphAPI.GetNode( 'root' )
    time = NodegraphAPI.GetCurrentTime()
    producer = Nodes3DAPI.GetGeometryProducer( node, time)
    prod = producer.getProducerByPath('/root')
    WalkBoundAttrLocations(prod)

    # extract the dip for each map
    assetWithDisp = findDispHeight(fileOut)

    # create a stack of AttributeSet to set the disp if there is element in the dict
    if len(assetWithDisp.keys()):
        stack = NodegraphAPI.CreateNode("GroupStack", NodegraphAPI.GetRootNode())
        stack.setName('Attribute_Disp')
        stack.setChildNodeType("AttributeSet")
        listWord = ['/location/','/prop/','/location/','/character/']
        for key in assetWithDisp.keys():
            path = ''
            attributSet = stack.buildChildNode()
            attributSet.getParameter('mode').setValue('CEL',0)
            attrPath = attributSet.getParameter('celSelection')
            attributSet.getParameter('attributeType').setValue('float',0)
            # replace the word from listWord by the wildcard '/*' so to work in lighting scene
            for word in listWord:
                if key.find(word) > 1:
                    path = key.replace(word,'//*/')
                    attrPath.setValue(path,0)
                    break
                else:
                    attrPath.setValue(key,0)
            attributSet.setName(key[key.rfind('/')+1:]) # set name to the _hi
            attrValue = attributSet.getParameter('numberValue.i0')
            attrValue.setValue(assetWithDisp[key],0)
            attrName = attributSet.getParameter('attributeName')
            attrName.setValue('arnoldStatements.disp_padding',0)
        NodegraphAPI.SetNodePosition(stack,opscriptFindDispPos)
        stackInPort = stack.getInputPort('in')
        stackOutPort = stack.getOutputPort('out')
        nodeOutPort.connect(stackInPort)
        stackOutPort.connect(nextPort)
        NodegraphAPI.SetNodeViewed(stack, True, exclusive=True)
        NodegraphAPI.SetNodeEdited(stack, True, exclusive=True)
    else:  # reconnect the nodes
        nodeOutPort.connect(nextPort)
        NodegraphAPI.SetNodeViewed(node, True, exclusive=True)
        NodegraphAPI.SetNodeEdited(node, True, exclusive=True)

    # delete the opscript and the file
    opscriptFindDisp.delete()
    os.remove(fileOut)
    print 'finished'