def renderLogCallback(line): if "Writing image" in line: imageName = line.split("\"")[-2] # Display the render if not cmds.about(batch=True): MitsubaRendererUI.showRender(imageName)
def doIt(self,argList): global renderSettings print "Rendering with Mitsuba..." # Create a render settings node createRenderSettingsNode() #Save the user's selection userSelection = cmds.ls(sl=True) print( "Render Settings - Node : %s" % renderSettings ) #Get the directories and other variables projectDir = cmds.workspace(q=True, fn=True) renderDir = os.path.join(projectDir, "renderData") pluginDir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) version = cmds.about(v=True).replace(" ", "-") # Get render settings mitsubaPath = cmds.getAttr("%s.%s" % (renderSettings, "mitsubaPath")) oiiotoolPath = cmds.getAttr("%s.%s" % (renderSettings, "oiiotoolPath")) mtsDir = os.path.split(mitsubaPath)[0] integrator = cmds.getAttr("%s.%s" % (renderSettings, "integrator")) sampler = cmds.getAttr("%s.%s" % (renderSettings, "sampler")) sampleCount = cmds.getAttr("%s.%s" % (renderSettings, "sampleCount")) reconstructionFilter = cmds.getAttr("%s.%s" % (renderSettings, "reconstructionFilter")) keepTempFiles = cmds.getAttr("%s.%s" % (renderSettings, "keepTempFiles")) verbose = cmds.getAttr("%s.%s" % (renderSettings, "verbose")) print( "Render Settings - Mitsuba Path : %s" % mitsubaPath ) print( "Render Settings - Integrator : %s" % integrator ) print( "Render Settings - Sampler : %s" % sampler ) print( "Render Settings - Sample Count : %s" % sampleCount ) print( "Render Settings - Reconstruction : %s" % reconstructionFilter ) print( "Render Settings - Keep Temp Files : %s" % keepTempFiles ) print( "Render Settings - Verbose : %s" % verbose ) print( "Render Settings - Render Dir : %s" % renderDir ) print( "Render Settings - oiiotool Path : %s" % mitsubaPath ) animation = self.isAnimation() print( "Render Settings - Animation : %s" % animation ) # Animation if animation: startFrame = int(cmds.getAttr("defaultRenderGlobals.startFrame")) endFrame = int(cmds.getAttr("defaultRenderGlobals.endFrame")) byFrame = int(cmds.getAttr("defaultRenderGlobals.byFrameStep")) print( "Animation frame range : %d to %d, step %d" % ( startFrame, endFrame, byFrame) ) for frame in range(startFrame, endFrame+1, byFrame): print( "Rendering frame " + str(frame) + " - begin" ) self.exportAndRender(renderDir, renderSettings, mitsubaPath, oiiotoolPath, mtsDir, keepTempFiles, animation, frame, verbose) print( "Rendering frame " + str(frame) + " - end" ) print( "Animation finished" ) # Single frame else: imageName = self.exportAndRender(renderDir, renderSettings, mitsubaPath, oiiotoolPath, mtsDir, keepTempFiles, animation, None, verbose) # Display the render if not cmds.about(batch=True): MitsubaRendererUI.showRender(imageName) # Select the objects that the user had selected before they rendered, or clear the selection if len(userSelection) > 0: cmds.select(userSelection) else: cmds.select(cl=True)
def doIt(self, argList): global renderSettings print "Rendering with Mitsuba..." # Create a render settings node createRenderSettingsNode() #Save the user's selection userSelection = cmds.ls(sl=True) print("Render Settings - Node : %s" % renderSettings) #Get the directories and other variables projectDir = cmds.workspace(q=True, fn=True) renderDir = os.path.join(projectDir, "renderData") pluginDir = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))) version = cmds.about(v=True).replace(" ", "-") # Get render settings mitsubaPath = cmds.getAttr("%s.%s" % (renderSettings, "mitsubaPath")) oiiotoolPath = cmds.getAttr("%s.%s" % (renderSettings, "oiiotoolPath")) mtsDir = os.path.split(mitsubaPath)[0] integrator = cmds.getAttr("%s.%s" % (renderSettings, "integrator")) sampler = cmds.getAttr("%s.%s" % (renderSettings, "sampler")) sampleCount = cmds.getAttr("%s.%s" % (renderSettings, "sampleCount")) reconstructionFilter = cmds.getAttr( "%s.%s" % (renderSettings, "reconstructionFilter")) keepTempFiles = cmds.getAttr("%s.%s" % (renderSettings, "keepTempFiles")) verbose = cmds.getAttr("%s.%s" % (renderSettings, "verbose")) print("Render Settings - Mitsuba Path : %s" % mitsubaPath) print("Render Settings - Integrator : %s" % integrator) print("Render Settings - Sampler : %s" % sampler) print("Render Settings - Sample Count : %s" % sampleCount) print("Render Settings - Reconstruction : %s" % reconstructionFilter) print("Render Settings - Keep Temp Files : %s" % keepTempFiles) print("Render Settings - Verbose : %s" % verbose) print("Render Settings - Render Dir : %s" % renderDir) print("Render Settings - oiiotool Path : %s" % mitsubaPath) animation = self.isAnimation() print("Render Settings - Animation : %s" % animation) # Animation if animation: startFrame = int(cmds.getAttr("defaultRenderGlobals.startFrame")) endFrame = int(cmds.getAttr("defaultRenderGlobals.endFrame")) byFrame = int(cmds.getAttr("defaultRenderGlobals.byFrameStep")) print("Animation frame range : %d to %d, step %d" % (startFrame, endFrame, byFrame)) for frame in range(startFrame, endFrame + 1, byFrame): print("Rendering frame " + str(frame) + " - begin") self.exportAndRender(renderDir, renderSettings, mitsubaPath, oiiotoolPath, mtsDir, keepTempFiles, animation, frame, verbose) print("Rendering frame " + str(frame) + " - end") print("Animation finished") # Single frame else: imageName = self.exportAndRender(renderDir, renderSettings, mitsubaPath, oiiotoolPath, mtsDir, keepTempFiles, animation, None, verbose) # Display the render if not cmds.about(batch=True): MitsubaRendererUI.showRender(imageName) # Select the objects that the user had selected before they rendered, or clear the selection if len(userSelection) > 0: cmds.select(userSelection) else: cmds.select(cl=True)