def export_renderer_output(node):
    """
    """
    module_logger.debug("RendererOutputExport - export_renderer_output()")

    export_logger = logging.getLogger(
        "katana_addons.Plugins.RendererOutputExport.Export")
    export_logger.setLevel(int(
        node.getParameter("Debug.logLevel").getValue(0)))

    from PyUtilModule import NodeDebugOutput

    export_geometry_producer = Nodes3DAPI.GetGeometryProducer(node)
    renderer = (export_geometry_producer.getAttribute(
        "renderSettings.renderer").getValue()
                or RenderingAPI.RenderPlugins.GetDefaultRendererPluginName())

    NodeDebugOutput.WriteRenderDebug(
        node=node,
        renderer=renderer,
        filename=node.getParameter("filename").getValue(0),
        expandProcedural=node.getParameter(
            "Export.expandProcedurals").getValue(0),
        openInEditor=False,
        customEditor=None,
        log=export_logger)
Ejemplo n.º 2
0
    def __populate(self):
        """
        Populates the UI.
        """
        showLights = self.__displayMode & DISPLAY_LIGHTS
        showCameras = self.__displayMode & DISPLAY_CAMERAS

        if self.__displayMode == (DISPLAY_LIGHTS | DISPLAY_CAMERAS):
            showLights = self.__lightsCheckbox.isChecked()
            showCameras = self.__camerasCheckbox.isChecked()


        self.__pathToDisplayInfo = {}
        self.clear()

        items = []

        # Add builtin cameras
        if showCameras:
            for builtin_camera in LightPickerButton.__builtins:
                items.append((builtin_camera, None, (builtin_camera + 'Shape', 'camera')))
                self.__pathToDisplayInfo[builtin_camera+'Shape'] = (builtin_camera, '')

        prod = Nodes3DAPI.GetGeometryProducer(self.__node)
        world = prod.getChildByName('world')

        if showCameras:
            # Build camera list
            globalsGroup = world.getAttribute("globals")
            camList = globalsGroup.childByName("cameraList")
            if camList:
                camera_locations = camList.getNearestSample(0)
                camera_locations.sort()

            abbreviatedCameraLocationNames = GeoAPI.ScenegraphUtils.AbbreviateScenegraphLocations(
                camera_locations)
            for fullLoc,shortLoc in zip(camera_locations,abbreviatedCameraLocationNames):
                items.append((shortLoc, self.__pixmaps['camera'], (fullLoc, 'camera')))
                self.__pathToDisplayInfo[fullLoc] = (shortLoc, 'camera')
        if showLights:
            # Build light list
            light_locations = []
            lightList = world.getAttribute("lightList")
            if lightList:
                for lightKey, lightAttr in lightList.childDict().items():
                    path = lightAttr.childByName("path")
                    lightPath = path.getNearestSample(0)[0]
                    light_locations.append(lightPath)

            light_locations.sort()
            abbreviatedLightLocationNames = GeoAPI.ScenegraphUtils.AbbreviateScenegraphLocations(
                light_locations)
            for fullLoc,shortLoc in zip(light_locations,abbreviatedLightLocationNames):
                items.append((shortLoc, self.__pixmaps['light'], (fullLoc, 'light')))
                self.__pathToDisplayInfo[fullLoc] = (shortLoc, 'light')


        for (shortLoc, pixmap, meta) in items:
            self.addItem(shortLoc, pixmap=pixmap, meta=meta)
Ejemplo n.º 3
0
 def displayModel(self,node=NodegraphAPI.GetRootNode(), nameInNode='_hiShape'):
     allPath =[]
     nameInNode = self.namelineEdit.text()
     node = NodegraphAPI.GetNode( 'root' )
     sg = ScenegraphManager.getActiveScenegraph()
     time = NodegraphAPI.GetCurrentTime()
     producer = Nodes3DAPI.GetGeometryProducer(node, time)
     splitText = str(self.pathLineEdit.text()).split(' ')
     if len(splitText) > 0 and splitText[0] != '' :
         for prodpath in splitText:
             producer =producer.getProducerByPath(prodpath)
             a = self.recursiveFindPath(producer, allPath, nameInNode=nameInNode)
             producer = Nodes3DAPI.GetGeometryProducer(node, time)
     else:
         allPath = self.recursiveFindPath(producer, listPath=[], nameInNode=nameInNode)
     for item in allPath:
         sg.addPinnedLocation(item)
Ejemplo n.º 4
0
def createMeshLights(gafferNode,
                     celExpression,
                     lightName="",
                     rigName="",
                     mode="Append",
                     lightType="mesh"):
    client = utils.getClient(node=gafferNode)
    geoProducer = Nodes3DAPI.GetGeometryProducer(gafferNode)
    collectedLocations = GeoAPI.Util.CelUtil.CollectPathsFromCELStatement(
        client, celExpression)

    rootPackage = gafferNode.getRootPackage()
    if mode == "Override":
        for package in rootPackage.getChildPackages():
            package.delete()

    rigName = rigName or "{}LightsRig".format(lightType)
    rigPackage = rootPackage.createChildPackage("RigPackage", rigName)
    mmPackage = rootPackage.createChildPackage(
        "MasterMaterialPackage", "{}MasterMaterial".format(rigName))
    mmPackage.setShader("arnoldLight", "{}_light".format(lightType))

    for idx, location in enumerate(collectedLocations):
        cookedLocation = client.cookLocation(location)
        if cookedLocation.getAttrs().getChildByName("type").getValue() not in (
                "subdmesh", "polymesh"):
            continue
        name = lightName or "{}Light".format(os.path.basename(location))
        lightPackage = rigPackage.createChildPackage("LightPackage",
                                                     "{}_{}".format(name, idx))
        lightPackage.setMasterMaterial(mmPackage)
        materialNode = lightPackage.getMaterialNode()
        materialNode.checkDynamicParameters()
        if lightType == "mesh":
            materialNode.getParameter(
                'shaders.arnoldLightParams.mesh.enable').setValue(True, 0.0)
            materialNode.getParameter(
                'shaders.arnoldLightParams.mesh.value').setValue(
                    location, 0.0)
        elif lightType == "point":
            bounds = GeoAPI.Transform.ProducerWorldBounds(
                geoProducer.getProducerByPath(location))
            centerX = (bounds[0] + bounds[1]) / 2
            centerY = (bounds[2] + bounds[3]) / 2
            centerZ = (bounds[4] + bounds[5]) / 2
            materialNode.getParameter(
                'shaders.arnoldLightParams.position.enable').setValue(
                    True, 0.0)
            materialNode.getParameter(
                'shaders.arnoldLightParams.position.value.i0').setValue(
                    centerX, 0.0)
            materialNode.getParameter(
                'shaders.arnoldLightParams.position.value.i1').setValue(
                    centerY, 0.0)
            materialNode.getParameter(
                'shaders.arnoldLightParams.position.value.i2').setValue(
                    centerZ, 0.0)
Ejemplo n.º 5
0
def get_producer(knode, location=None):
    '''
    :description get the scenegraph location producer
    :prama knode <Nodegraph Node Object>
    :param location <str>
    :example
        from core import scenegraph
        knode = NodegraphAPI.GetAllSelectedNodes()[0]
        scenegraph.get_producer(knode, location=None)    
    '''
    NodegraphAPI.SetNodeViewed(knode, True, exclusive=True)
    producer = Nodes3DAPI.GetGeometryProducer(node=knode)
    if location:
        producer = producer.getProducerByPath(location)
    return producer
Ejemplo n.º 6
0
def _GetLocationType(node, location):
    """
    Get the 'type' attribute value for the given location, using the Op tree
    for the given node.

    @type node: C{Node}
    @type location: C{str}
    @rtype: C{str} or C{None}
    @param node: The node to calculate the scenegraph for
    @param location: The scenegraph location to query the type of
    @return: The location type as a string, or C{None} if the location wasn't
        found or the type attribute wasn't found
    """
    producer = Nodes3DAPI.GetGeometryProducer(node)
    if not producer:
        return None

    locationProducer = producer.getProducerByPath(location)
    if not locationProducer:
        return None

    attr = locationProducer.getAttribute("type")
    if attr:
        return attr.getData()[0]
Ejemplo n.º 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'
Ejemplo n.º 8
0
def getRootProducer(t='geometry'):
    # type='geometry' or 'render'
    if t == 'geometry':
        return Nodes3DAPI.GetGeometryProducer()
    return Nodes3DAPI.GetRenderProducer()