def hyperRender(): gamma = mc.floatSliderGrp("gamma", q=True, v=True) width = mc.intFieldGrp("Resolution", q=True, value1=True) height = mc.intFieldGrp("Resolution", q=True, value2=True) fr = mc.textFieldButtonGrp("setFile", q=True, text=True) + "/" mc.eval mc.select(lights) mc.select(meshes, add=True) mc.showHidden(a=True) for m in meshes: hideChildren(m) for l in lights: mc.hide(l) for mesh in meshes: # hideChildren(mesh) for light in lights: mc.select(cl=True) mc.select(mesh) mc.select(light, add=True) showChildren(mesh) mc.showHidden(light) name = mesh + light + "output" mc.setAttr("defaultArnoldDriver.ai_translator", "png", type="string") mc.setAttr("defaultArnoldDriver.pre", name, type="string") arnoldRender(width, height, True, True, 'RenderCam_', ' -layer defaultRenderLayer') #render stuff here editor = 'renderView' #render_output = mc.renderer(editor, e=True) # mc.eval('renderWindowRender redoPreviousRender renderView') # editor = 'renderView' formatManager = createImageFormats.ImageFormats() formatManager.pushRenderGlobalsForDesc("PNG") mc.renderWindowEditor(editor, e=True, ga=gamma, com=True, cme=True, writeImage=fr + name + '.png') exec("print 'file saved to' + fr+name+'.png'") formatManager.popRenderGlobals() mc.hide(light) hideChildren(mesh)
def Render(k, *args): formatManager = createImageFormats.ImageFormats() formatManager.pushRenderGlobalsForDesc("JPEG") mc.render() global renderpath mc.renderWindowEditor(makeCamera.editor, crc=str(makeCamera.cam[0]), e=True, writeImage=str(renderpath[0] + '/testImage' + str(k) + '.jpg')) formatManager.popRenderGlobals()
def savePicInRenderView(frameIndex, x): # save the image to a exist folder editor = 'renderView' formatManager = createImageFormats.ImageFormats() formatManager.pushRenderGlobalsForDesc("PNG") # The name of the Image is CharacterImage'+str(x)+.jpg ,example CharacterImage1.jpg\ cmds.renderWindowEditor( editor, e=True, writeImage='E:/mayaStore/images/imageSequence/CharacterImage_' + str(frameIndex).zfill(2) + '_' + str(x).zfill(2) + '.png') formatManager.popRenderGlobals() #Test Function #renderSequence(0,24,renderfn_args = getCameraCharacter())
def take_screenshot(cam_name): cmds.select(allDagObjects=True) #place the camera to front view and fit the entire obj inside the camera view cmds.viewSet(f=True, fit=True) #take screenshot from the selected view-point, here front formatManager = createImageFormats.ImageFormats() cmds.setAttr('hardwareRenderingGlobals.renderMode', 4) cmds.setAttr('hardwareRenderingGlobals.lightingMode', 0) mel.eval('RenderViewWindow') tmp_image_path = cmds.ogsRender(cam=cam_name) formatManager.pushRenderGlobalsForDesc('PNG') cmds.refresh(cv=True, fe="jpg", fn="imageSnapshot")
def _blast(start, end, res, verbose=0): """Execute a playblast. Args: start (int): start frame end (int): end frame res (tuple): override image resolution verbose (int): print process data """ _seq = _get_blast_seq() if res: _width, _height = res else: _width = cmds.getAttr('defaultResolution.width') _height = cmds.getAttr('defaultResolution.height') lprint('RES', _width, _height, verbose=verbose) # Set image format _fmt_mgr = createImageFormats.ImageFormats() _fmt_mgr.pushRenderGlobalsForDesc({ 'jpg': "JPEG", 'exr': "EXR", }[_seq.extn]) _filename = '{}/{}'.format(_seq.dir, _seq.basename) cmds.playblast(startTime=start, endTime=end, format='image', filename=_filename, viewer=False, width=_width, height=_height, offScreen=True, percent=100) _fmt_mgr.popRenderGlobals()
def blast(seq, range_=None, res=None, force=False, cam=None, view=False, verbose=0): """Execute a playblast. Args: seq (Seq): output sequence range_ (tuple): start/end frame res (tuple): override image resolution force (bool): overwrite existing images without confirmation cam (str): override camera view (bool): view blast on complete verbose (int): print process data """ from psyhive import host from maya_psyhive import ui # Get res if res: _width, _height = res cmds.setAttr('defaultResolution.width', _width) cmds.setAttr('defaultResolution.height', _height) else: _width = cmds.getAttr('defaultResolution.width') _height = cmds.getAttr('defaultResolution.height') lprint('RES', _width, _height, verbose=verbose) # Get range _rng = range_ or host.t_range() _start, _end = _rng if cam: _panel = ui.get_active_model_panel() cmds.modelEditor(_panel, edit=True, camera=cam) seq.delete(wording='Replace', force=force) seq.test_dir() # Set image format _fmt_mgr = createImageFormats.ImageFormats() _fmt_mgr.pushRenderGlobalsForDesc({ 'jpg': "JPEG", 'exr': "EXR", }[seq.extn]) _filename = '{}/{}'.format(seq.dir, seq.basename) lprint('BLAST FILENAME', _filename, verbose=verbose) cmds.playblast(startTime=_start, endTime=_end, format='image', filename=_filename, viewer=False, width=_width, height=_height, offScreen=True, percent=100) assert seq.get_frames(force=True) _fmt_mgr.popRenderGlobals() if view: seq.view()