def registerArnoldRenderer():
    try:
        alreadyRegistered = pm.renderer('arnold', exists=True)
        if not alreadyRegistered:

            pm.evalDeferred(_register)

            # AE Templates
            # the following must occur even in batch mode because they contain calls to registerDefaultTranslator
            pm.evalDeferred(aeUtils.loadAETemplates)
            import rendererCallbacks
            rendererCallbacks.registerCallbacks()
            import mtoa.ui.ae.customShapeAttributes
            import mtoa.ui.ae.customShaderTemplates
            if not pm.about(batch=True):
                # Reload the AE Window if it has already been opened
                pm.evalDeferred(aeUtils.rebuildAE)
                # create the Arnold menu
                createArnoldMenu()

            # version specific overrides or additions
            _overridePythonScripts()
            _overrideMelScripts()

            # Add option box for file translator
            utils.pyToMelProc(exportass.arnoldAssOpts,
                              [('string', 'parent'), ('string', 'action'),
                               ('string', 'initialSettings'),
                               ('string', 'resultCallback')],
                              useName=True)

            # callbacks
            import mtoa.core as core
            core.installCallbacks()
            core.MTOA_GLOBALS['COMMAND_PORT'] = None

            import maya.cmds as cmds
            if not pm.about(batch=True):
                commandPortBase = 4700
                try:
                    commandPortBase = int(os.environ['MTOA_COMMAND_PORT'])
                except:
                    commandPortBase = 4700
                # opening a command port for different tools and maya batch progress messages
                for port in range(commandPortBase, commandPortBase + 100):
                    commandPortName = ':%i' % port
                    try:
                        cmds.commandPort(name=commandPortName)
                        core.MTOA_GLOBALS['COMMAND_PORT'] = port
                        break
                    except:
                        pass
            if not pm.about(batch=True):
                pm.evalDeferred(arnoldShelf.createArnoldShelf)
    except:
        import traceback
        traceback.print_exc(file=sys.__stderr__)
        raise
Ejemplo n.º 2
0
def registerArnoldRenderer():
    try:
        alreadyRegistered = pm.renderer('arnold', exists=True)
        if not alreadyRegistered:

            pm.evalDeferred(_register)

            # AE Templates
            # the following must occur even in batch mode because they contain calls to registerDefaultTranslator
            pm.evalDeferred(aeUtils.loadAETemplates)
            import rendererCallbacks
            rendererCallbacks.registerCallbacks()
            import mtoa.ui.ae.customShapeAttributes
            import mtoa.ui.ae.customShaderTemplates
            if not pm.about(batch=True):
                # Reload the AE Window if it has already been opened
                pm.evalDeferred(aeUtils.rebuildAE)
                # create the Arnold menu
                createArnoldMenu()

            # version specific overrides or additions
            _overridePythonScripts()
            _overrideMelScripts()

            # Add option box for file translator
            utils.pyToMelProc(exportass.arnoldAssOpts,
                              [('string', 'parent'), ('string', 'action'),
                               ('string', 'initialSettings'), ('string', 'resultCallback')],
                               useName=True)
            
            # callbacks
            import mtoa.core as core
            core.installCallbacks()
            core.MTOA_GLOBALS['COMMAND_PORT'] = None

            import maya.cmds as cmds
            if not pm.about(batch=True):
                commandPortBase = 4700
                try:
                    commandPortBase = int(os.environ['MTOA_COMMAND_PORT'])
                except:
                    commandPortBase = 4700
                # opening a command port for different tools and maya batch progress messages
                for port in range(commandPortBase, commandPortBase + 100):
                    commandPortName = ':%i' % port
                    try:
                        cmds.commandPort(name=commandPortName)
                        core.MTOA_GLOBALS['COMMAND_PORT'] = port
                        break
                    except:
                        pass
            if not pm.about(batch=True):
                pm.evalDeferred(arnoldShelf.createArnoldShelf)
    except:
        import traceback
        traceback.print_exc(file=sys.__stderr__)
        raise
Ejemplo n.º 3
0
def _addAEHooks():
    """
    in versions of Maya prior to 2013 there is no way to override built-in AE templates.
    """
    # Realflow uses the AEshapeHooks global variable as a convention for sharing AEshapeTemplate overrides,
    # so we will too, unless a more popular convention is found.
    pm.melGlobals.initVar('string[]', 'AEshapeHooks')
    hooks = list(pm.melGlobals['AEshapeHooks'])
    import mtoa.ui.ae.templates
    procName = utils.pyToMelProc(mtoa.ui.ae.templates.loadArnoldTemplate, [('string', 'nodeName')], useName=True)
    hooks.append(procName)
    pm.melGlobals['AEshapeHooks'] = hooks
def _addAEHooks():
    """
    in versions of Maya prior to 2013 there is no way to override built-in AE templates.
    """
    # Realflow uses the AEshapeHooks global variable as a convention for sharing AEshapeTemplate overrides,
    # so we will too, unless a more popular convention is found.
    pm.melGlobals.initVar('string[]', 'AEshapeHooks')
    hooks = list(pm.melGlobals['AEshapeHooks'])
    import mtoa.ui.ae.templates
    procName = utils.pyToMelProc(mtoa.ui.ae.templates.loadArnoldTemplate,
                                 [('string', 'nodeName')],
                                 useName=True)
    hooks.append(procName)
    pm.melGlobals['AEshapeHooks'] = hooks
Ejemplo n.º 5
0
def _register():
    args = {}
    args['renderProcedure'] = utils.pyToMelProc(arnoldRender.arnoldRender,
                                          [('int', 'width'), ('int', 'height'),
                                           ('int', 'doShadows'), ('int', 'doGlowPass'),
                                           ('string', 'camera'), ('string', 'options')])
    args['renderRegionProcedure'] = 'mayaRenderRegion'
    args['commandRenderProcedure']    = utils.pyToMelProc(arnoldRender.arnoldBatchRender,
                                                    [('string', 'option')])
    args['batchRenderProcedure']        = utils.pyToMelProc(arnoldRender.arnoldBatchRender,
                                                    [('string', 'option')])
    args['batchRenderOptionsStringProcedure'] = utils.pyToMelProc(arnoldRender.arnoldBatchRenderOptionsString, returnType='string')
    args['cancelBatchRenderProcedure']  = utils.pyToMelProc(arnoldRender.arnoldBatchStop)
    args['iprRenderProcedure']          = utils.pyToMelProc(arnoldRender.arnoldIprRender,
                                                    [('int', 'width'), ('int', 'height'),
                                                     ('int', 'doShadows'), ('int', 'doGlowPass'),
                                                     ('string', 'camera')])
    args['isRunningIprProcedure']       = utils.pyToMelProc(arnoldRender.arnoldIprIsRunning, returnType='int')
    args['startIprRenderProcedure']     = utils.pyToMelProc(arnoldRender.arnoldIprStart,
                                                    [('string', 'editor'), ('int', 'resolutionX'),
                                                     ('int', 'resolutionY'), ('string', 'camera')])
    args['stopIprRenderProcedure']      = utils.pyToMelProc(arnoldRender.arnoldIprStop)
    args['refreshIprRenderProcedure']   = utils.pyToMelProc(arnoldRender.arnoldIprRefresh)
    args['pauseIprRenderProcedure']     =   utils.pyToMelProc(arnoldRender.arnoldIprPause,
                                                    [('string', 'editor'), ('int', 'pause')])
    args['changeIprRegionProcedure']    = utils.pyToMelProc(arnoldRender.arnoldIprChangeRegion,
                                                    [('string', 'renderPanel')])
    pm.renderer('arnold', rendererUIName='Arnold Renderer', **args)
        
    pm.renderer('arnold', edit=True, addGlobalsTab=('Common',
                                                      utils.pyToMelProc(createArnoldRendererCommonGlobalsTab, useName=True),
                                                      utils.pyToMelProc(updateArnoldRendererCommonGlobalsTab, useName=True)))
    pm.renderer('arnold', edit=True, addGlobalsTab=('Arnold Renderer',
                                                      utils.pyToMelProc(createArnoldRendererGlobalsTab, useName=True),
                                                      utils.pyToMelProc(updateArnoldRendererGlobalsTab, useName=True)))
    pm.renderer('arnold', edit=True, addGlobalsTab=('System', 
                                                      utils.pyToMelProc(createArnoldRendererSystemTab, useName=True), 
                                                      utils.pyToMelProc(updateArnoldRendererSystemTab, useName=True)))
    pm.renderer('arnold', edit=True, addGlobalsTab=('AOVs', 
                                                      utils.pyToMelProc(createArnoldAOVTab, useName=True), 
                                                      utils.pyToMelProc(updateArnoldAOVTab, useName=True)))
    pm.renderer('arnold', edit=True, addGlobalsTab=('Diagnostics', 
                                                      utils.pyToMelProc(createArnoldRendererDiagnosticsTab, useName=True), 
                                                      utils.pyToMelProc(updateArnoldRendererDiagnosticsTab, useName=True)))
    pm.renderer('arnold', edit=True, addGlobalsTab=('Override', 
                                                      utils.pyToMelProc(createArnoldRendererOverrideTab, useName=True), 
                                                      utils.pyToMelProc(updateArnoldRendererOverrideTab, useName=True)))
    pm.renderer('arnold', edit=True, addGlobalsNode='defaultArnoldRenderOptions')
    utils.pyToMelProc(updateBackgroundSettings, useName=True)
    utils.pyToMelProc(updateAtmosphereSettings, useName=True)
    #We have to source this file otherwise maya will override
    #our mel proc overrides below.
    #
    pm.mel.source('createMayaSoftwareCommonGlobalsTab.mel')
    
    utils.pyToMelProc(addOneTabToGlobalsWindow,
                      [('string', 'renderer'), ('string', 'tabLabel'), ('string', 'createProc')],
                      useName=True)
    utils.pyToMelProc(renderSettingsTabLabel_melToUI,
                      [('string', 'mel')],
                      useName=True)
    utils.pyToMelProc(updateMayaImageFormatControl,
                      useName=True)
Ejemplo n.º 6
0
def aeCallback(func):
    return utils.pyToMelProc(func, [('string', 'nodeName')],
                             procPrefix='AEArnoldCallback')
def _register():
    args = {}
    args['renderProcedure'] = utils.pyToMelProc(arnoldRender.arnoldRender,
                                                [('int', 'width'),
                                                 ('int', 'height'),
                                                 ('int', 'doShadows'),
                                                 ('int', 'doGlowPass'),
                                                 ('string', 'camera'),
                                                 ('string', 'options')])
    args['renderRegionProcedure'] = 'mayaRenderRegion'
    args['commandRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldBatchRender, [('string', 'option')])
    args['batchRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldBatchRender, [('string', 'option')])
    args['batchRenderOptionsStringProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldBatchRenderOptionsString, returnType='string')
    args['cancelBatchRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldBatchStop)
    args['iprRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldIprRender, [('int', 'width'), ('int', 'height'),
                                       ('int', 'doShadows'),
                                       ('int', 'doGlowPass'),
                                       ('string', 'camera')])
    args['isRunningIprProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldIprIsRunning, returnType='int')
    args['startIprRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldIprStart, [('string', 'editor'),
                                      ('int', 'resolutionX'),
                                      ('int', 'resolutionY'),
                                      ('string', 'camera')])
    args['stopIprRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldIprStop)
    args['refreshIprRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldIprRefresh)
    args['pauseIprRenderProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldIprPause, [('string', 'editor'), ('int', 'pause')])
    args['changeIprRegionProcedure'] = utils.pyToMelProc(
        arnoldRender.arnoldIprChangeRegion, [('string', 'renderPanel')])
    pm.renderer('arnold', rendererUIName='Arnold Renderer', **args)

    pm.renderer(
        'arnold',
        edit=True,
        addGlobalsTab=('Common',
                       utils.pyToMelProc(createArnoldRendererCommonGlobalsTab,
                                         useName=True),
                       utils.pyToMelProc(updateArnoldRendererCommonGlobalsTab,
                                         useName=True)))
    pm.renderer(
        'arnold',
        edit=True,
        addGlobalsTab=('Arnold Renderer',
                       utils.pyToMelProc(createArnoldRendererGlobalsTab,
                                         useName=True),
                       utils.pyToMelProc(updateArnoldRendererGlobalsTab,
                                         useName=True)))
    pm.renderer('arnold',
                edit=True,
                addGlobalsTab=('System',
                               utils.pyToMelProc(createArnoldRendererSystemTab,
                                                 useName=True),
                               utils.pyToMelProc(updateArnoldRendererSystemTab,
                                                 useName=True)))
    pm.renderer('arnold',
                edit=True,
                addGlobalsTab=('AOVs',
                               utils.pyToMelProc(createArnoldAOVTab,
                                                 useName=True),
                               utils.pyToMelProc(updateArnoldAOVTab,
                                                 useName=True)))
    pm.renderer(
        'arnold',
        edit=True,
        addGlobalsTab=('Diagnostics',
                       utils.pyToMelProc(createArnoldRendererDiagnosticsTab,
                                         useName=True),
                       utils.pyToMelProc(updateArnoldRendererDiagnosticsTab,
                                         useName=True)))
    pm.renderer(
        'arnold',
        edit=True,
        addGlobalsTab=('Override',
                       utils.pyToMelProc(createArnoldRendererOverrideTab,
                                         useName=True),
                       utils.pyToMelProc(updateArnoldRendererOverrideTab,
                                         useName=True)))
    pm.renderer('arnold',
                edit=True,
                addGlobalsNode='defaultArnoldRenderOptions')
    utils.pyToMelProc(updateBackgroundSettings, useName=True)
    utils.pyToMelProc(updateAtmosphereSettings, useName=True)
    #We have to source this file otherwise maya will override
    #our mel proc overrides below.
    #
    pm.mel.source('createMayaSoftwareCommonGlobalsTab.mel')

    utils.pyToMelProc(addOneTabToGlobalsWindow, [('string', 'renderer'),
                                                 ('string', 'tabLabel'),
                                                 ('string', 'createProc')],
                      useName=True)
    utils.pyToMelProc(renderSettingsTabLabel_melToUI, [('string', 'mel')],
                      useName=True)
    utils.pyToMelProc(updateMayaImageFormatControl, useName=True)
Ejemplo n.º 8
0
def aeCallback(func):
    return utils.pyToMelProc(func, [('string', 'nodeName')], procPrefix='AEArnoldCallback')
Ejemplo n.º 9
0
        #
        pm.mel.buildCreateSubMenu(staticClass, '%s %s ""' % (_createNodeCallbackProc,
                                                             runtimeClass) )
        pm.setParent('..', menu=True)

def createNodeCallback(runtimeClassification, postCommand, nodeType):

    node = unicode(createArnoldNode(nodeType, runtimeClassification=runtimeClassification))
    if postCommand:
        postCommand = postCommand.replace('%node', node).replace('%type', nodeType).replace(r'\"','"')
        pm.mel.eval(postCommand)
    return node

_createNodeCallbackProc = utils.pyToMelProc(createNodeCallback, 
                                            [('string', 'runtimeClassification'),
                                             ('string', 'postCommand'),
                                             ('string', 'nodeType')],
                                             returnType='string')

# names of the following procs mirror mental ray naming convention, so the inconsistency is not ours

# make the global proc available for the renderCReateBarUI.mel override
utils.pyToMelProc(createArnoldNodesTreeLister_Content,
                                       [('string', 'renderNodeTreeLister'),
                                        ('string', 'postCommand'),
                                        ('string', 'filterString')], useName=True)

# make the global proc available for the hyperShadePanel.mel override
utils.pyToMelProc(aiHyperShadeCreateMenu_BuildMenu, useName=True)