def renderFrame(self):
     """ Gather all information from UI to render current frame """
     # get width and height
     modelPanel = lib.getActiveModelPanel()
     width = cmds.modelEditor(modelPanel, w=True, q=True)
     height = cmds.modelEditor(modelPanel, h=True, q=True)
     if self.frameCapCustomChBox.isChecked():
         width = self.frameCapWSpin.value()
         height = self.frameCapHSpin.value()
     # get render size (supersampling or not)
     renderSize = 1
     if self.supersampleImgChBox.isChecked():
         renderSize = 2
     # get save directory
     fileFilter = "*" + self.frameCapFormatCoBox.currentText()
     saveDir = cmds.fileDialog2(fileFilter=fileFilter,
                                fileMode=0,
                                cap="Save image in:",
                                dialogStyle=2)
     if not saveDir:
         cmds.error("Filename not specified")
     saveDir = saveDir[0]
     # get image format
     imgFormat = self.frameCapFormatCoBox.currentText()
     # get renderer
     override = mnpr_info.prototype
     if not self.viewport2RenderChBox.isChecked():
         override = ""
     # render frame using npr system
     mnpr_system.renderFrame(saveDir, width, height, renderSize, imgFormat,
                             override)
Beispiel #2
0
def check():
    """Makes sure everything is running right"""
    print("SYSTEM CHECK FOR {0}".format(mnpr_info.prototype))
    # check viewport
    viewport = lib.getActiveModelPanel()
    cmds.modelEditor(viewport, dtx=True, e=True)  # display textures

    # plugin needs to be loaded
    mnpr_info.loadRenderer()

    # 3rd party plugins must be loaded
    cmds.loadPlugin('shaderFXPlugin', quiet=True)
    if cmds.about(nt=True, q=True):
        cmds.loadPlugin(
            'dx11Shader',
            quiet=True)  # deprecated (only shadeFXPlugin in the future)
    cmds.loadPlugin(
        'glslShader',
        quiet=True)  # deprecated (only shaderFXPlugin in the future)

    # viewport renderer must be set
    mel.eval("setRendererAndOverrideInModelPanel vp2Renderer {0} {1};".format(
        mnpr_info.prototype, viewport))

    # modify color of heads up display
    cmds.displayColor("headsUpDisplayLabels", 2, dormant=True)
    cmds.displayColor("headsUpDisplayValues", 2, dormant=True)

    # make sure a config node exists
    if not cmds.objExists(mnpr_info.configNode):
        selected = cmds.ls(sl=True, l=True)
        selectConfig()
        cmds.select(selected, r=True)

    lib.printInfo("-> SYSTEM CHECK SUCCESSFUL")
def showOnlyPlayblast():
    '''show only geometry (smoothShaded)'''
    currentModelPanel = lib.getActiveModelPanel()
    if currentModelPanel:
        hideAllDisplayObjects(currentModelPanel)
        cmds.modelEditor(currentModelPanel, e=True, ns=True) #nurbs surfaces
        cmds.modelEditor(currentModelPanel, e=True, pm=True) #polygons
        cmds.modelEditor(currentModelPanel, e=True, displayAppearance='smoothShaded')
    else:
        cmds.warning("No active model panel"),
def showOnlyLayout():
    '''show only nurbs, polys (flatshaded) and cameras'''
    currentModelPanel = lib.getActiveModelPanel()
    if currentModelPanel:
        hideAllDisplayObjects(currentModelPanel)
        cmds.modelEditor(currentModelPanel, e=True, ns=True) #nurbs surfaces
        cmds.modelEditor(currentModelPanel, e=True, pm=True) #polygons
        cmds.modelEditor(currentModelPanel, e=True, ca=True) #cameras
        cmds.modelEditor(currentModelPanel, e=True, motionTrails=True) #motion trails
        cmds.modelEditor(currentModelPanel, e=True, greasePencils=True) #grease pencil
        cmds.modelEditor(currentModelPanel, e=True, displayAppearance='flatShaded')
    else:
        cmds.warning("No active model panel"),
def showOnlyAnim():
    '''show only nurbs (surfaces, curves) and polys (smoothshaded)'''
    currentModelPanel = lib.getActiveModelPanel()
    if currentModelPanel:
        hideAllDisplayObjects(currentModelPanel)
        cmds.modelEditor(currentModelPanel, e=True, ns=True) #nurbs surfaces
        cmds.modelEditor(currentModelPanel, e=True, nc=True) #nurbs curves
        cmds.modelEditor(currentModelPanel, e=True, pm=True) #polygons
        cmds.modelEditor(currentModelPanel, e=True, motionTrails=True) #motion trails
        cmds.modelEditor(currentModelPanel, e=True, greasePencils=True) #grease pencil
        cmds.modelEditor(currentModelPanel, e=True, displayAppearance='smoothShaded')
    else:
        cmds.warning("No active model panel"),
def showOnlyRigging():
    currentModelPanel = lib.getActiveModelPanel()
    if currentModelPanel:
        hideAllDisplayObjects(currentModelPanel)
        #probably show all?
        cmds.modelEditor(currentModelPanel, e=True, ns=True) #nurbs surfaces
        cmds.modelEditor(currentModelPanel, e=True, nc=True) #nurbs curves
        cmds.modelEditor(currentModelPanel, e=True, pm=True) #polygons
        cmds.modelEditor(currentModelPanel, e=True, j=True) #joints
        cmds.modelEditor(currentModelPanel, e=True, jx=True) #x-ray joints
        cmds.modelEditor(currentModelPanel, e=True, ikh=True) #IK handles
        cmds.modelEditor(currentModelPanel, e=True, df=True) #deformers
        cmds.modelEditor(currentModelPanel, e=True, dy=True) #dynamics
        cmds.modelEditor(currentModelPanel, e=True, lc=True) #locators
        cmds.modelEditor(currentModelPanel, e=True, displayAppearance='smoothShaded')
    else:
        cmds.warning("No active model panel"),
 def playblast(self):
     """ Gather all information from UI to playblast current timeline """
     # FROM VIEWPORT
     # get width and height
     modelPanel = lib.getActiveModelPanel()
     width = cmds.modelEditor(modelPanel, w=True, q=True)
     height = cmds.modelEditor(modelPanel, h=True, q=True)
     # get camera to work from
     currentCamera = cmds.modelEditor(modelPanel, cam=True, q=True)
     currentCameraShape = cmds.listRelatives(currentCamera, s=True)
     if currentCameraShape:
         currentCameraShape = currentCameraShape[0]
     else:
         # we already had the camera shape
         currentCameraShape = currentCamera
     renderCamera = currentCameraShape  # in case none is selected as renderable
     # FROM RENDER SETTINGS
     if self.playblastSettingsRenderRaBtn.isChecked():
         # get with and height
         width = cmds.getAttr("defaultResolution.width")
         height = cmds.getAttr("defaultResolution.height")
         # get camera
         cameras = cmds.ls(type='camera')
         for cam in cameras:
             if cmds.getAttr("{0}.renderable".format(cam)) == 1:
                 renderCamera = cam
     # define where to playblast to
     fileFilter = "*.mov"
     saveDir = cmds.fileDialog2(fileFilter=fileFilter,
                                fileMode=0,
                                cap="Save video in:",
                                dialogStyle=2)
     if not saveDir:
         cmds.error("Filename not specified")
     saveDir = saveDir[0]
     # get render size (supersampling or not)
     renderSize = 1
     if self.supersamplePlbChBox.isChecked():
         renderSize = 2
     # playblast timeline using npr system
     print(renderSize)
     mnpr_system.playblast(saveDir, width, height, renderCamera, modelPanel,
                           renderSize)
Beispiel #8
0
def defaultLighting():
    """
    Creates the default lighting in the scene
    Useful when there is no lighting in the scene
    """
    # check if lights exist
    if cmds.ls(lt=True):
        return
    # save current selection
    selected = cmds.ls(sl=True, l=True)
    # create and place test light
    lightShape = cmds.directionalLight()
    lightXform = cmds.listRelatives(lightShape, p=True)[0]
    cmds.setAttr("{0}.tx".format(lightXform), 5)
    cmds.setAttr("{0}.ty".format(lightXform), 5)
    cmds.setAttr("{0}.ry".format(lightXform), 90)
    cmds.setAttr("{0}.rz".format(lightXform), 45)
    # activate lights on viewport
    viewport = lib.getActiveModelPanel()
    cmds.modelEditor(viewport, edit=True, displayLights="all")
    # bring back selection
    cmds.select(selected, r=True)
def hideAllDisplayObjects(modelPanel=None):
    '''hides all display objects of modelPanel'''
    if not modelPanel:
        modelPanel = lib.getActiveModelPanel()
    cmds.modelEditor(modelPanel, e=True, alo=False)