def imageToBlender(self):
			[sizeX, sizeY, bStartX, bStartY, bsizeX, bsizeY] = self.getRenderCoords()
			imageMem = yafrayinterface.new_floatArray(sizeX * sizeY * 4)
			memIO = yafrayinterface.memoryIO_t(sizeX, sizeY, imageMem)
			self.yi.getRenderedImage(memIO)
			self.memoryioToImage(imageMem, "yafRender", sizeX, sizeY, bStartX, bStartY, bsizeX, bsizeY)
			yafrayinterface.delete_floatArray(imageMem)
示例#2
0
文件: scene.py 项目: tpaviot/occray
    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
示例#3
0
 def imageToBlender(self):
     [sizeX, sizeY, bStartX, bStartY, bsizeX,
      bsizeY] = self.getRenderCoords()
     imageMem = yafrayinterface.new_floatArray(sizeX * sizeY * 4)
     memIO = yafrayinterface.memoryIO_t(sizeX, sizeY, imageMem)
     self.yi.getRenderedImage(memIO)
     self.memoryioToImage(imageMem, "yafRender", sizeX, sizeY, bStartX,
                          bStartY, bsizeX, bsizeY)
     yafrayinterface.delete_floatArray(imageMem)
	def createPreview(self, mat, size, job_id, imageMem):
		
		yi = self.yi
		yi.clearAll()
		yi.startScene(1)
		self.inputGamma = self.scene.properties["YafRay"]["Renderer"]["gammaInput"]
		yi.setInputGamma(self.inputGamma, True)

		self.textures = set()
		self.materials = set()

		# Textures
		self.processMaterialTextures(mat, job_id)
		
		# Material
		self.exportMaterial(mat)
		
		# Mesh
		yi.paramsClearAll()
		yi.paramsSetString("type", "sphere")
		yi.paramsSetPoint("center", 0, 0, 0)
		yi.paramsSetFloat("radius", 2)
		yi.paramsSetString("material", namehash(mat))
		yi.createObject("Sphere1")
		
		
		# Lights
		yi.paramsClearAll()
		yi.paramsSetColor("color", 1, 1, 1, 1)
		yi.paramsSetPoint("from", 11, 3, 8)
		yi.paramsSetFloat("power", 160)
		yi.paramsSetString("type", "pointlight")
		yi.createLight("LAMP1")

		yi.paramsClearAll()
		yi.paramsSetColor("color", 1, 1, 1, 1)
		yi.paramsSetPoint("from", -2, -10, 2)
		yi.paramsSetFloat("power", 18)
		yi.paramsSetString("type", "pointlight")
		yi.createLight("LAMP2")
		
		# Background
		yi.paramsClearAll()
		yi.paramsSetString("type", "sunsky")
		yi.paramsSetPoint("from", 1, 1, 1)
		yi.paramsSetFloat("turbidity", 3)
		yi.createBackground("world_background")
		
		# Camera
		yi.paramsClearAll()
		yi.paramsSetString("type", "perspective")
		yi.paramsSetFloat("focal", 2.4)
		yi.paramsSetPoint("from", 7, -7, 4.15)
		yi.paramsSetPoint("up", 6.12392, -6.11394, 7.20305)
		yi.paramsSetPoint("to", 4.89145, -4.88147, 2.90031)
		yi.paramsSetInt("resx", size)
		yi.paramsSetInt("resy", size)
		yi.createCamera("cam")
		
		# Integrators
		yi.paramsClearAll()
		yi.paramsSetString("type", "directlighting")
		yi.createIntegrator("default")
		
		yi.paramsClearAll()
		yi.paramsSetString("type", "none")
		yi.createIntegrator("volintegr")
		
		# Render
		yi.paramsClearAll()
		yi.paramsSetString("camera_name", "cam")
		yi.paramsSetString("integrator_name", "default")
		yi.paramsSetString("volintegrator_name", "volintegr")

		yi.paramsSetFloat("gamma", 1.8)
		yi.paramsSetInt("AA_passes", 1)
		yi.paramsSetInt("AA_minsamples", 1)
		yi.paramsSetFloat("AA_pixelwidth", 1.5)
		yi.paramsSetString("filter_type", "Mitchell")

		co = yafrayinterface.memoryIO_t(size, size, imageMem)

		yi.paramsSetInt("width", size)
		yi.paramsSetInt("height", size)

		yi.paramsSetBool("z_channel", False)

		yi.paramsSetString("background_name", "world_background")

		yi.render(co)
		yi.clearAll()
		
		self.yMaterial.materialMap.clear()
示例#5
0
    def createPreview(self, mat, size, imageMem):

        yi = self.yi
        yi.clearAll()
        yi.startScene(1)
        self.inputGamma = self.scene.properties["YafRay"]["Renderer"][
            "gammaInput"]
        yi.setInputGamma(self.inputGamma, True)

        self.textures = set()
        self.materials = set()

        # Textures
        self.processMaterialTextures(mat)

        # Material
        self.exportMaterial(mat)

        # Mesh
        yi.paramsClearAll()
        yi.paramsSetString("type", "sphere")
        yi.paramsSetPoint("center", 0, 0, 0)
        yi.paramsSetFloat("radius", 2)
        yi.paramsSetString("material", namehash(mat))
        yi.createObject("Sphere1")

        # Lights
        yi.paramsClearAll()
        yi.paramsSetColor("color", 1, 1, 1, 1)
        yi.paramsSetPoint("from", 11, 3, 8)
        yi.paramsSetFloat("power", 160)
        yi.paramsSetString("type", "pointlight")
        yi.createLight("LAMP1")

        yi.paramsClearAll()
        yi.paramsSetColor("color", 1, 1, 1, 1)
        yi.paramsSetPoint("from", -2, -10, 2)
        yi.paramsSetFloat("power", 18)
        yi.paramsSetString("type", "pointlight")
        yi.createLight("LAMP2")

        # Background
        yi.paramsClearAll()
        yi.paramsSetString("type", "sunsky")
        yi.paramsSetPoint("from", 1, 1, 1)
        yi.paramsSetFloat("turbidity", 3)
        yi.createBackground("world_background")

        # Camera
        yi.paramsClearAll()
        yi.paramsSetString("type", "perspective")
        yi.paramsSetFloat("focal", 2.4)
        yi.paramsSetPoint("from", 7, -7, 4.15)
        yi.paramsSetPoint("up", 6.12392, -6.11394, 7.20305)
        yi.paramsSetPoint("to", 4.89145, -4.88147, 2.90031)
        yi.paramsSetInt("resx", size)
        yi.paramsSetInt("resy", size)
        yi.createCamera("cam")

        # Integrators
        yi.paramsClearAll()
        yi.paramsSetString("type", "directlighting")
        yi.createIntegrator("default")

        yi.paramsClearAll()
        yi.paramsSetString("type", "none")
        yi.createIntegrator("volintegr")

        # Render
        yi.paramsClearAll()
        yi.paramsSetString("camera_name", "cam")
        yi.paramsSetString("integrator_name", "default")
        yi.paramsSetString("volintegrator_name", "volintegr")

        yi.paramsSetFloat("gamma", 1.8)
        yi.paramsSetInt("AA_passes", 1)
        yi.paramsSetInt("AA_minsamples", 1)
        yi.paramsSetFloat("AA_pixelwidth", 1.5)
        yi.paramsSetString("filter_type", "Mitchell")

        co = yafrayinterface.memoryIO_t(size, size, imageMem)

        yi.paramsSetInt("width", size)
        yi.paramsSetInt("height", size)

        yi.paramsSetBool("z_channel", False)

        yi.paramsSetString("background_name", "world_background")

        yi.render(co)
        yi.clearAll()

        self.yMaterial.materialMap.clear()