Exemple #1
0
 def stop(self):
     if self.timeChange != None:
         OM.MEventMessage.removeCallback(self.timeChange)
         self.timeChange = None
     try:
         cmds.arnoldIpr(mode='stop')
         sys.stdout.write("// Info: Aton - Render stopped.\n")
     except RuntimeError:
         pass
Exemple #2
0
    def render(self):
        """ Starts the render """
        try:  # If MtoA was not found
            defaultTranslator = cmds.getAttr("defaultArnoldDisplayDriver.aiTranslator")
        except ValueError:
            cmds.warning("Current renderer is not set to Arnold.")
            return

        cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", "aton", type="string")

        # Updating the port from UI
        if self.defaultPort != 0:
            port = self.portSpinBox.value()
            cmds.setAttr("defaultArnoldDisplayDriver.port", port)
        else:
            cmds.warning("Current renderer is not set to Arnold or Aton driver is not loaded.")
            return

        # Adding time changed callback
        if self.timeChangedCB == None:
            self.timeChangedCB = OM.MEventMessage.addEventCallback("timeChanged", self.timeChnaged)

        # Adding selection changed callback
        if self.selectionChangedCB == None:
            self.selectionChangedCB = OM.MEventMessage.addEventCallback("SelectionChanged", self.selectionChanged)

        try:  # If render session is not started yet
            cmds.arnoldIpr(mode="stop")
        except RuntimeError:
            pass

        # Temporary makeing hidden cameras visible before scene export
        hCams = [
            x
            for x in cmds.listCameras()
            if not cmds.getAttr("%s.visibility" % x)
            or not cmds.getAttr("%s.visibility" % cmds.listRelatives(x, s=1)[0])
        ]
        for i in hCams:
            cmds.showHidden(i)

        try:  # Start IPR
            camera = self.getCamera()
            cmds.arnoldIpr(cam=camera, mode="start")
        except RuntimeError:
            cmds.warning("Current renderer is not set to Arnold.")

        # Update IPR
        self.IPRUpdate()
        sys.stdout.write("// Info: Aton - Render started.\n")

        # Setting back to default
        for i in hCams:
            cmds.hide(i)
        cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", defaultTranslator, type="string")
        cmds.setAttr("defaultArnoldDisplayDriver.port", self.defaultPort)
Exemple #3
0
	def render(self):
		try:
			cmds.arnoldIpr(mode='stop')
		except RuntimeError:
			pass

		defaultTranslator = cmds.getAttr("defaultArnoldDisplayDriver.aiTranslator")

		try:
			cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", "aton", type="string")
		except RuntimeError:
			cmds.warning("Aton driver for Arnold is not installed")
			return

		if self.cameraComboBox.currentIndex() == 0:
			camera = self.getSceneOptions()["camera"]
		else:
			camera = cmds.listRelatives(self.cameraComboBoxDict[self.cameraComboBox.currentIndex()], s=1)[0]

		width = self.getSceneOptions()["width"] * self.resolutionSpinBox.value() / 100
		height = self.getSceneOptions()["height"] * self.resolutionSpinBox.value() / 100
		AASamples = self.cameraAaSpinBox.value()
		motionBlur = not self.motionBlurCheckBox.isChecked()
		subdivs = not self.subdivsCheckBox.isChecked()
		displace = not self.displaceCheckBox.isChecked()
		bump = not self.bumpCheckBox.isChecked()
		sss = not self.sssCheckBox.isChecked()

		rMinX = self.renderRegionXSpinBox.value()
		rMinY = height - self.renderRegionTSpinBox.value()
		rMaxX = self.renderRegionRSpinBox.value() -1
		rMaxY = (height - self.renderRegionYSpinBox.value()) - 1
		print rMinX, rMinY, rMaxX, rMaxY
		core.createOptions()
		cmds.arnoldIpr(cam=camera, width=width, height=height, mode='start')
		nodeIter = AiUniverseGetNodeIterator(AI_NODE_ALL)

		while not AiNodeIteratorFinished(nodeIter):
			node = AiNodeIteratorGetNext(nodeIter)
			AiNodeSetInt(node, "AA_samples", AASamples)
			if rMinX >= 0 and rMinY>=0 and rMaxX<=width and rMaxY<=height:
				AiNodeSetInt(node, "region_min_x", rMinX)
				AiNodeSetInt(node, "region_min_y", rMinY)
				AiNodeSetInt(node, "region_max_x", rMaxX)
				AiNodeSetInt(node, "region_max_y", rMaxY)
			AiNodeSetBool(node, "ignore_motion_blur", motionBlur)
			AiNodeSetBool(node, "ignore_subdivision", subdivs)
			AiNodeSetBool(node, "ignore_displacement ", displace)
			AiNodeSetBool(node, "ignore_bump", bump)
			AiNodeSetBool(node, "ignore_sss", sss)

		# Temp trigger in order to start IPR immediately
		cmds.setAttr("%s.bestFitClippingPlanes"%camera, True)

		cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", defaultTranslator, type="string")
Exemple #4
0
    def stop(self):
        """ Stops the render session and removes the callbacks """
        if self.timeChangedCB != None:
            OM.MEventMessage.removeCallback(self.timeChangedCB)
            self.timeChangedCB = None

        if self.selectionChangedCB != None:
            OM.MEventMessage.removeCallback(self.selectionChangedCB)
            self.selectionChangedCB = None

        try:
            cmds.arnoldIpr(mode="stop")
            sys.stdout.write("// Info: Aton - Render stopped.\n")
        except (AttributeError, RuntimeError):
            return
Exemple #5
0
def arnoldIprRender(width, height, doShadows, doGlowPass, camera):
    cmds.arnoldIpr(cam=camera, w=width, h=height, mode=render)
Exemple #6
0
    def render(self, *args, **kwargs):

        if self.cameraComboBox.currentIndex() == 0:
            camera = self.getSceneOptions()["camera"]
        else:
            try:
                camera = cmds.listRelatives(self.cameraComboBoxDict[self.cameraComboBox.currentIndex()], s=1)[0]
            except TypeError:
                camera = self.cameraComboBoxDict[self.cameraComboBox.currentIndex()]

        if camera == None:
            cmds.warning("Camera is not selected!")
            return

        try:
            defaultTranslator = cmds.getAttr("defaultArnoldDisplayDriver.aiTranslator")
        except:
            cmds.warning("MtoA was not found.")
            return

        try:
            cmds.arnoldIpr(mode='stop')
        except RuntimeError:
            pass

        try:
            cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", "aton", type="string")
        except RuntimeError:
            cmds.warning("Aton driver for Arnold is not installed")
            return

        port = self.portSpinBox.value()
        width = self.getSceneOptions()["width"] * self.resolutionSpinBox.value() / 100
        height = self.getSceneOptions()["height"] * self.resolutionSpinBox.value() / 100
        AASamples = self.cameraAaSpinBox.value()
        motionBlur = self.motionBlurCheckBox.isChecked()
        subdivs = self.subdivsCheckBox.isChecked()
        displace = self.displaceCheckBox.isChecked()
        bump = self.bumpCheckBox.isChecked()
        sss = self.sssCheckBox.isChecked()

        rMinX = self.renderRegionXSpinBox.value()
        rMinY = height - self.renderRegionTSpinBox.value()
        rMaxX = self.renderRegionRSpinBox.value() -1
        rMaxY = (height - self.renderRegionYSpinBox.value()) - 1

        cmds.setAttr("defaultArnoldDisplayDriver.port", port)

        # Adding time changed callback
        if self.timeChange == None:
            self.timeChange = OM.MEventMessage.addEventCallback( "timeChanged", self.updateFrame )

        cmds.arnoldIpr(cam=camera, width=width, height=height, mode='start')

        options = AiUniverseGetOptions()

        AiNodeSetInt(options, "AA_samples", AASamples)
        if rMinX >= 0 and rMinY>=0 and rMaxX<=width and rMaxY<=height:
            AiNodeSetInt(options, "region_min_x", rMinX)
            AiNodeSetInt(options, "region_min_y", rMinY)
            AiNodeSetInt(options, "region_max_x", rMaxX)
            AiNodeSetInt(options, "region_max_y", rMaxY)
        AiNodeSetBool(options, "ignore_motion_blur", motionBlur)
        AiNodeSetBool(options, "ignore_subdivision", subdivs)
        AiNodeSetBool(options, "ignore_displacement", displace)
        AiNodeSetBool(options, "ignore_bump", bump)
        AiNodeSetBool(options, "ignore_sss", sss)

        # Temp trigger in order to start IPR
        time = cmds.currentTime(q=1)
        cmds.currentTime(time, e=1)

        cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", defaultTranslator, type="string")
        cmds.setAttr("defaultArnoldDisplayDriver.port", self.defaultPort)
        sys.stdout.write("// Info: Aton - Render started.\n")
Exemple #7
0
def stopRender():
    if core.ACTIVE_CAMERA != None:
        cmds.arnoldIpr(cam=core.ACTIVE_CAMERA, m='stop')
Exemple #8
0
def refreshRender():
    if core.ACTIVE_CAMERA != None:
        cmds.arnoldIpr(cam=core.ACTIVE_CAMERA, m='refresh')
Exemple #9
0
def startIpr():
    if core.ACTIVE_CAMERA != None:
        cmds.arnoldIpr(cam=core.ACTIVE_CAMERA, m='start')
Exemple #10
0
    def IPRUpdate(self, attr=None):
        ''' This method is called during IPR session '''
        try: # If render session is not started yet
            cmds.arnoldIpr(mode='pause')
        except (AttributeError, RuntimeError):
            return

        options = AiUniverseGetOptions()

        # Camera Update
        if attr == None or attr == 0:
            camera = self.getCamera()
            iterator = AiUniverseGetNodeIterator(AI_NODE_CAMERA)
            while not AiNodeIteratorFinished(iterator):
                node = AiNodeIteratorGetNext(iterator)
                if AiNodeGetName(node) == camera:
                    AiNodeSetPtr(options, "camera", node)

        # Resolution and Region Update
        if attr == None or attr == 1:

            AiNodeSetInt(options, "xres", self.getRegion(0))
            AiNodeSetInt(options, "yres", self.getRegion(1))

            AiNodeSetInt(options, "region_min_x", self.getRegion(2))
            AiNodeSetInt(options, "region_min_y", self.getRegion(3))
            AiNodeSetInt(options, "region_max_x", self.getRegion(4))
            AiNodeSetInt(options, "region_max_y", self.getRegion(5))

        # Camera AA Update
        if attr == None or attr == 2:
            cameraAA = self.cameraAaSpinBox.value()
            options = AiUniverseGetOptions()
            AiNodeSetInt(options, "AA_samples", cameraAA)

        # Ignore options Update
        if attr == None or attr == 3:
            motionBlur = self.motionBlurCheckBox.isChecked()
            subdivs = self.subdivsCheckBox.isChecked()
            displace = self.displaceCheckBox.isChecked()
            bump = self.bumpCheckBox.isChecked()
            sss = self.sssCheckBox.isChecked()

            AiNodeSetBool(options, "ignore_motion_blur", motionBlur)
            AiNodeSetBool(options, "ignore_subdivision", subdivs)
            AiNodeSetBool(options, "ignore_displacement", displace)
            AiNodeSetBool(options, "ignore_bump", bump)
            AiNodeSetBool(options, "ignore_sss", sss)

        # Storing default shader assignments
        if attr == None:
            self.initOvrShaders()
            self.shadersDict = {}
            iterator = AiUniverseGetNodeIterator(AI_NODE_SHAPE)
            while not AiNodeIteratorFinished(iterator):
                node = AiNodeIteratorGetNext(iterator)
                name = AiNodeGetName(node)
                try: # If object name is not exist i.e. "root"
                    sgList = cmds.listConnections(name, type='shadingEngine')
                    if sgList > 0:
                        self.shadersDict[name] = AiNodeGetPtr(node, "shader")
                except ValueError:
                    continue

        # Shader override Update
        shaderIndex = self.shaderComboBox.currentIndex()
        if attr == 4 or shaderIndex > 0:
            iterator = AiUniverseGetNodeIterator(AI_NODE_SHAPE)
            while not AiNodeIteratorFinished(iterator):
                node = AiNodeIteratorGetNext(iterator)
                name = AiNodeGetName(node)

                selChecked = self.selectedShaderCheckbox.isChecked()
                if shaderIndex != 0 and selChecked:
                    selectionList = cmds.ls(dag=1, sl=1, s=1)
                    if selectionList > 0 and name not in selectionList:
                        if name in self.shadersDict:
                            defShader = self.shadersDict[AiNodeGetName(node)]
                            AiNodeSetPtr(node, "shader", defShader)
                        continue

                # Setting overrides
                if name in self.shadersDict:
                    defShader = self.shadersDict[AiNodeGetName(node)]
                    result = {0: lambda: AiNodeSetPtr(node, "shader", defShader),
                              1: lambda: AiNodeSetPtr(node, "shader", self.checkerShader),
                              2: lambda: AiNodeSetPtr(node, "shader", self.greyShader),
                              3: lambda: AiNodeSetPtr(node, "shader", self.mirrorShader),
                              4: lambda: AiNodeSetPtr(node, "shader", self.normalShader),
                              5: lambda: AiNodeSetPtr(node, "shader", self.occlusionShader),
                              6: lambda: AiNodeSetPtr(node, "shader", self.uvShader)}[shaderIndex]()

        # Texture Repeat Udpate
        if attr == None or attr == 5:
            texRepeat = self.textureRepeatSpinbox.value()
            AiNodeSetPnt2(self.placeTexture, "repeatUV", texRepeat, texRepeat)

        try:
            cmds.arnoldIpr(mode='unpause')
        except RuntimeError:
            pass
Exemple #11
0
    def render(self):
        ''' Starts the render '''
        try: # If MtoA was not found
            defaultTranslator = cmds.getAttr("defaultArnoldDisplayDriver.aiTranslator")
        except ValueError:
            cmds.warning("Current renderer is not set to Arnold.")
            return

        cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", "aton", type="string")

        # Updating extraHost and port from UI
        if self.defaultPort != 0:
            extraHost = self.extraHostLineEdit.text()
            port = self.portSpinBox.value()
            cmds.setAttr("defaultArnoldDisplayDriver.extraHost", extraHost, type="string")
            cmds.setAttr("defaultArnoldDisplayDriver.port", port)
        else:
            cmds.warning("Current renderer is not set to Arnold or Aton driver is not loaded.")
            return

        # Adding time changed callback
        if self.timeChangedCB == None:
            self.timeChangedCB = OM.MEventMessage.addEventCallback("timeChanged", self.timeChnaged)

        # Adding selection changed callback
        if self.selectionChangedCB == None:
            self.selectionChangedCB = OM.MEventMessage.addEventCallback('SelectionChanged', self.selectionChanged)

        try: # If render session is not started yet
            cmds.arnoldIpr(mode='stop')
        except RuntimeError:
            pass

        # Temporary makeing hidden cameras visible before scene export
        hCams = []
        for i in cmds.listCameras():
            if not cmds.getAttr(i + ".visibility"):
                hCams.append(i)
            sl = cmds.listRelatives(i, s=1)
            if sl and not cmds.getAttr(sl[0] + ".visibility"):
                hCams.append(sl[0])

        for i in hCams: cmds.showHidden(i)

        # Set Progressive refinement to off
        if self.sequence_enabled:
            cmds.setAttr("defaultArnoldRenderOptions.progressive_rendering", False)

        try: # Start IPR
            cmds.arnoldIpr(cam=self.getCamera(), mode='start')
            sys.stdout.write("// Info: Aton - Render started.\n")
        except RuntimeError:
            cmds.warning("Current renderer is not set to Arnold.")

        # Sequence Rendering
        if self.sequence_enabled:
            self.frame_sequence.start()

        # Update IPR
        self.IPRUpdate()

        # Setting back to default
        for i in hCams: cmds.hide(i)
        cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", defaultTranslator, type="string")
        cmds.setAttr("defaultArnoldDisplayDriver.port", self.defaultPort)
Exemple #12
0
def arnoldIprIsRunning():
    return cmds.arnoldIpr()
Exemple #13
0
def arnoldIprStop():
    cmds.arnoldIpr(mode="stop")
Exemple #14
0
def arnoldIprStart(editor, resolutionX, resolutionY, camera):
    # Make sure the aiOptions node exists
    core.createOptions()
    cmds.arnoldIpr(cam=camera, w=resolutionX, h=resolutionY, mode="start")
Exemple #15
0
def arnoldIprChangeRegion(renderPanel):
    cmds.arnoldIpr(mode="region")
Exemple #16
0
def arnoldIprPause(editor, pause):
    if pause:
        cmds.arnoldIpr(mode="pause")
    else:
        cmds.arnoldIpr(mode="unpause")
Exemple #17
0
def arnoldIprRefresh():
    cmds.arnoldIpr(mode="refresh")
Exemple #18
0
	def stop(self):
		cmds.arnoldIpr(mode='stop')
Exemple #19
0
    def render(self):
        ''' Starts the render '''
        try: # If MtoA was not found
            defaultTranslator = cmds.getAttr("defaultArnoldDisplayDriver.aiTranslator")
        except ValueError:
            cmds.warning("Current renderer is not set to Arnold.")
            return

        cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", "aton", type="string")

        # Updating the port from UI
        if self.defaultPort != 0:
            port = self.portSpinBox.value()
            cmds.setAttr("defaultArnoldDisplayDriver.port", port)
        else:
            cmds.warning("Current renderer is not set to Arnold or Aton driver is not loaded.")
            return

        # Adding time changed callback
        if self.timeChangedCB == None:
            self.timeChangedCB = OM.MEventMessage.addEventCallback("timeChanged", self.timeChnaged)

        # Adding selection changed callback
        if self.selectionChangedCB == None:
            self.selectionChangedCB = OM.MEventMessage.addEventCallback('SelectionChanged', self.selectionChanged)

        try: # If render session is not started yet
            cmds.arnoldIpr(mode='stop')
        except RuntimeError:
            pass

        # Temporary makeing hidden cameras visible before scene export
        hCams = [x for x in cmds.listCameras() if not cmds.getAttr("%s.visibility"%x) or
                                                  not cmds.getAttr("%s.visibility"%cmds.listRelatives(x, s=1)[0])]
        for i in hCams: cmds.showHidden(i)

        if self.sequence_enabled: # set level to 2 before ipr starts
            # Store progressive_inital_level
            # Set it to 2 so we run only 1 iteration per frame
            level = 'defaultArnoldRenderOptions.progressive_initial_level'
            self.default_level = cmds.getAttr(level)
            cmds.setAttr(level, 2)

        try: # Start IPR
            camera = self.getCamera()
            cmds.arnoldIpr(cam=camera, mode='start')
        except RuntimeError:
            cmds.warning("Current renderer is not set to Arnold.")

        # Sequence Rendering
        if self.sequence_enabled:
            self.frame_sequence.start()

        # Update IPR
        self.IPRUpdate()
        sys.stdout.write("// Info: Aton - Render started.\n")

        # Setting back to default
        for i in hCams: cmds.hide(i)
        cmds.setAttr("defaultArnoldDisplayDriver.aiTranslator", defaultTranslator, type="string")
        cmds.setAttr("defaultArnoldDisplayDriver.port", self.defaultPort)