def startRender(self, renderCoords, frameNumber=None): yi = self.yi # sizeX/Y is the actual size of the image, b* is bordered stuff [sizeX, sizeY, bStartX, bStartY, bsizeX, bsizeY] = renderCoords autoSave = self.renderer.autoSave doAnimation = (frameNumber != None) ## saveToMem = renderprops["imageToBlender"] saveToMem = False closeAfterFinish = False ret = 0 if self.useXML: saveToMem = False co = yafrayinterface.outTga_t(0, 0, "") outputFile = self.getOutputFilename(None, False) outputFile += '.xml' print "INFO: Writing XML:", outputFile yi.render(co) # single frame output without GUI elif not self.haveQt: outputFile = self.getOutputFilename(frameNumber) outputFile += '.tga' print "INFO: Rendering to file:", outputFile co = yafrayinterface.outTga_t(sizeX, sizeY, outputFile) yi.render(co) else: import yafqt outputFile = self.getOutputFilename(frameNumber) outputFile += '.png' yafqt.initGui() guiSettings = yafqt.Settings() guiSettings.autoSave = autoSave guiSettings.closeAfterFinish = closeAfterFinish guiSettings.mem = None guiSettings.fileName = outputFile ## guiSettings.autoSaveAlpha = renderprops["autoalpha"] guiSettings.autoSaveAlpha = False if doAnimation: guiSettings.autoSave = True guiSettings.closeAfterFinish = True # will return > 0 if user canceled the rendering using ESC ret = yafqt.createRenderWidget(self.yi, sizeX, sizeY, bStartX, bStartY, guiSettings) if saveToMem and not doAnimation: imageMem = yafrayinterface.new_floatArray(sizeX * sizeY * 4) memIO = yafrayinterface.memoryIO_t(sizeX, sizeY, imageMem) yi.getRenderedImage(memIO) self.memoryioToImage(imageMem, "yafRender", sizeX, sizeY, bStartX, bStartY, bsizeX, bsizeY) yafrayinterface.delete_floatArray(imageMem) return ret
def startRender(self, renderCoords, output, frameNumber=None): yi = self.yi scene = self.scene render = scene.getRenderingContext() renderprops = scene.properties["YafRay"]["Renderer"] # sizeX/Y is the actual size of the image, b* is bordered stuff [sizeX, sizeY, bStartX, bStartY, bsizeX, bsizeY] = renderCoords [co, outputFile] = output autoSave = renderprops["autoSave"] doAnimation = (frameNumber != None) ret = 0 if self.scene.properties["YafRay"]["Renderer"][ "output_method"] == "XML": yi.render(co) # single frame output without GUI elif self.scene.properties["YafRay"]["Renderer"][ "output_method"] == "GUI" and haveQt: import yafqt yafqt.initGui() guiSettings = yafqt.Settings() guiSettings.autoSave = autoSave guiSettings.closeAfterFinish = False guiSettings.mem = None guiSettings.fileName = outputFile guiSettings.autoSaveAlpha = renderprops["autoalpha"] if doAnimation: guiSettings.autoSave = True guiSettings.closeAfterFinish = True # will return > 0 if user canceled the rendering using ESC ret = yafqt.createRenderWidget(self.yi, sizeX, sizeY, bStartX, bStartY, guiSettings) else: yi.render(co) return ret
def startRender(self, renderCoords, output, frameNumber = None): yi = self.yi scene = self.scene render = scene.getRenderingContext() renderprops = scene.properties["YafRay"]["Renderer"] # sizeX/Y is the actual size of the image, b* is bordered stuff [sizeX, sizeY, bStartX, bStartY, bsizeX, bsizeY] = renderCoords [co, outputFile] = output autoSave = renderprops["autoSave"] doAnimation = (frameNumber != None) ret = 0 if self.scene.properties["YafRay"]["Renderer"]["output_method"] == "XML": yi.render(co) # single frame output without GUI elif self.scene.properties["YafRay"]["Renderer"]["output_method"] == "GUI" and haveQt: import yafqt yafqt.initGui() guiSettings = yafqt.Settings() guiSettings.autoSave = autoSave guiSettings.closeAfterFinish = False guiSettings.mem = None guiSettings.fileName = outputFile guiSettings.autoSaveAlpha = renderprops["autoalpha"] if doAnimation: guiSettings.autoSave = True guiSettings.closeAfterFinish = True # will return > 0 if user canceled the rendering using ESC ret = yafqt.createRenderWidget(self.yi, sizeX, sizeY, bStartX, bStartY, guiSettings) else: yi.render(co) return ret
def yafarayRenderer(obj, app, settings): """ This function exports data in a format that can be used to reconstruct the humanoid object in YafaRay. It supports a range of options that can be specified in the Python script file mh2yafaray_ini.py, which is reloaded each time this function is run. This enables these options to be changed while the MakeHuman application is still running. Parameters ---------- obj: *3D object*. The object to export. This should be the humanoid object with uv-mapping data and Face Groups defined. camera: *Camera object*. The camera to render from """ print 'YafaRay Export of object: ', obj.name # Read settings from an ini file. This reload enables the settings to be # changed dynamically without forcing the user to restart the MH # application for the changes to take effect. camera = app.modelCamera resolution = (app.settings.get('rendering_width', 800), app.settings.get('rendering_height', 600)) reload(mh2yafaray_ini) path = os.path.join(mh.getPath('render'), mh2yafaray_ini.outputpath) source = mh2yafaray_ini.source if settings['source'] == 'gui' else settings['source'] action = mh2yafaray_ini.action lighting = mh2yafaray_ini.lighting if settings['lighting'] == 'dl' else settings['lighting'] world = mh2yafaray_ini.world if settings['world'] == 'texture' else settings['world'] image_path = mh2yafaray_ini.yafaray_path if action == 'render': if source == 'xml': yi = yafrayinterface.xmlInterface_t() else: yi = yafrayinterface.yafrayInterface_t() yi.loadPlugins(mh2yafaray_ini.PLUGIN_PATH) #-- yi.startScene() #-- texture ---- yafarayTexture(yi, image_path) #-- create material ---- yafarayMaterial(yi) #-- lights ---- yafarayLights(yi) #-- geometry ---- yafarayGeometry(yi, obj) #-- create cam ---- yafarayCameraData(yi, camera, resolution) #-- background ---- yafarayBackground(yi, world) #-- integrator ---- yafarayIntegrators(yi, lighting) #-- output ---- if source == 'console': yi.paramsClearAll() path_net = str(path).replace("\"","/") # use / for campatibility by Unix systems ? file_type = 'tga' # To do; create option in GUI ? yi.paramsSetString("type", file_type) yi.paramsSetBool("alpha_channel", False) yi.paramsSetBool("z_channel", False) yi.paramsSetInt("width", resolution[0]) yi.paramsSetInt("height", resolution[1]) ih = yi.createImageHandler("outFile") output = yafrayinterface.imageOutput_t(ih, path_net + 'test.tga', 0, 0) # Todo; revised for Unix systems # if source == 'xml': output = yafrayinterface.imageOutput_t() #-- render options ---- yafarayRender(yi, resolution) #-- QT interface ---- if source == 'gui': import yafqt yafqt.initGui() guiSettings = yafqt.Settings() guiSettings.autoSave = False guiSettings.closeAfterFinish = False guiSettings.mem = None #guiSettings.fileName = 'test.png' guiSettings.autoSaveAlpha = False #-- create render window yafqt.createRenderWidget(yi, resolution[0], resolution[1], 0, 0, guiSettings) else: yi.render(output) yi.clearAll()