Exemplo n.º 1
0
    def render(self, scene):
        debug.Debug("render()")

        vrayExporter = self._get_settings()
        use_std = vrayExporter.backend == 'STD'

        if use_std:
            super().render(scene)
        elif self.renderer:
            _vray_for_blender_rt.render(self.renderer)
Exemplo n.º 2
0
    def render(self, scene):
        if not self.doRender():
            return
        debug.Debug("render()")

        vrayExporter = self.getExporter()
        use_std = vrayExporter.backend == 'STD'

        if use_std:
            super().render(scene)
            if bpy.app.background:
                # free renderer so we close and flush all files
                self._free_renderer()
                # in backgorund mode we render only once, so exit here to force
                # Blender not rendering more frames and not wrinting files
                sys.exit(0)
        elif self.renderer:
            _vray_for_blender_rt.render(self.renderer)
Exemplo n.º 3
0
    def render(self, scene):
        if not self.doRender():
            return
        debug.Debug("render()")

        vrayExporter = self.getExporter()
        use_std = vrayExporter.backend == 'STD'

        if use_std:
            super().render(scene)
            if bpy.app.background:
                # free renderer so we close and flush all files
                self._free_renderer()
                # in backgorund mode we render only once, so exit here to force
                # Blender not rendering more frames and not wrinting files
                sys.exit(0)
        elif self.renderer:
            _vray_for_blender_rt.render(self.renderer)
Exemplo n.º 4
0
def ExportEx(bus):
    debug.Debug("ExportEx()")

    err = None

    scene = bus['scene']
    engine = bus['engine']
    o = bus['output']

    VRayScene = scene.vray
    VRayExporter = VRayScene.Exporter
    VRayDR = VRayScene.VRayDR

    pm = VRayFilePaths()

    # Setting user defined value here
    # It could be overriden in 'initFromScene'
    # depending on VRayDR settings
    pm.setSeparateFiles(VRayExporter.useSeparateFiles)

    pm.initFromScene(engine, scene)
    pm.printInfo()

    fm = VRayExportFiles(pm)
    fm.setOverwriteGeometry(VRayExporter.auto_meshes)

    try:
        fm.init()
    except Exception as e:
        debug.ExceptionInfo(e)
        return "Error initing files!"

    o.setFileManager(fm)
    o.setPreview(engine.is_preview)

    bus['exporter'] = exp_init.InitExporter(bus)

    try:
        # We do everything here basically because we want to close files
        # if smth goes wrong...
        rtExporter = HAS_VB35 and engine.bl_idname == 'VRAY_RENDER_RT'
        if not rtExporter:
            err = Export(bus, scene, engine, engine.is_preview)
        else:
            if not VRayExporter.animation_mode in {'NONE', 'CAMERA_LOOP'}:
                o.setAnimation(True)
                o.setFrameStart(scene.frame_start)
                o.setFrameEnd(scene.frame_end)
                o.setFrameStep(scene.frame_step)
            elif VRayExporter.animation_mode == 'CAMERA_LOOP':
                cameraCount = len([
                    1 for o in scene.objects
                    if o.type == 'CAMERA' and o.data.vray.use_camera_loop
                ])
                o.setAnimation(True)
                o.setFrameStart(1)
                o.setFrameEnd(cameraCount)
                o.setFrameStep(1)

            init = {
                'context': bpy.context.as_pointer(),
                'engine': engine.as_pointer(),
                'data': bpy.data.as_pointer(),
                'scene': scene.as_pointer(),
                'mainFile': fm.getFileByPluginType('MAIN'),
                'objectFile': fm.getFileByPluginType('OBJECT'),
                'envFile': fm.getFileByPluginType('WORLD'),
                'geometryFile': fm.getFileByPluginType('GEOMETRY'),
                'lightsFile': fm.getFileByPluginType('LIGHT'),
                'materialFile': fm.getFileByPluginType('MATERIAL'),
                'textureFile': fm.getFileByPluginType('TEXTURE'),
                'cameraFile': fm.getFileByPluginType('CAMERA'),
            }

            # Free anything we have
            if engine.renderer:
                del engine.renderer

            renderer = _vray_for_blender_rt.init(**init)
            if renderer:
                # Write settings for new exporter.
                # TODO: Move this to cpp.
                exp_settings.ExportSettings(bus)

                setattr(engine, 'renderer', renderer)

                _vray_for_blender_rt.render(renderer)

    except Exception as e:
        debug.ExceptionInfo(e)
        err = str(e)
    finally:
        exp_init.ShutdownExporter(bus)
        o.done()

    return err
Exemplo n.º 5
0
def ExportEx(bus):
    debug.Debug("ExportEx()")

    err = None

    scene  = bus['scene']
    engine = bus['engine']
    o      = bus['output']

    VRayScene    = scene.vray
    VRayExporter = VRayScene.Exporter

    pm = VRayFilePaths()

    # Setting user defined value here
    # It could be overriden in 'initFromScene'
    # depending on VRayDR settings
    pm.setSeparateFiles(VRayExporter.useSeparateFiles)

    pm.initFromScene(engine, scene)
    pm.printInfo()

    fm = VRayExportFiles(pm)
    fm.setOverwriteGeometry(VRayExporter.auto_meshes)

    rtExporter = HAS_VB35 and engine.bl_idname == 'VRAY_RENDER_RT'
    try:
        fm.init(not rtExporter)
    except Exception as e:
        debug.ExceptionInfo(e)
        return "Error initing files!"

    o.setFileManager(fm)
    o.setPreview(engine.is_preview)

    if not rtExporter:
        bus['exporter'] = exp_init.InitExporter(bus)

    try:
        # We do everything here basically because we want to close files
        # if smth goes wrong...
        if not rtExporter:
            err = Export(bus, scene, engine, engine.is_preview)
        else:
            if not VRayExporter.animation_mode in {'NONE', 'CAMERA_LOOP'}:
                o.setAnimation(True)
                o.setFrameStart(scene.frame_start)
                o.setFrameEnd(scene.frame_end)
                o.setFrameStep(scene.frame_step)
            elif VRayExporter.animation_mode == 'CAMERA_LOOP':
                cameraCount = len([1 for o in scene.objects if o.type == 'CAMERA' and o.data.vray.use_camera_loop])
                o.setAnimation(True)
                o.setFrameStart(1)
                o.setFrameEnd(cameraCount)
                o.setFrameStep(1)

            init = {
                'context'      : bpy.context.as_pointer(),
                'engine'       : engine.as_pointer(),
                'data'         : bpy.data.as_pointer(),
                'scene'        : scene.as_pointer(),
                'mainFile'     : fm.getFilePathByPluginType('MAIN'),
                'objectFile'   : fm.getFilePathByPluginType('OBJECT'),
                'envFile'      : fm.getFilePathByPluginType('WORLD'),
                'geometryFile' : fm.getFilePathByPluginType('GEOMETRY'),
                'lightsFile'   : fm.getFilePathByPluginType('LIGHT'),
                'materialFile' : fm.getFilePathByPluginType('MATERIAL'),
                'textureFile'  : fm.getFilePathByPluginType('TEXTURE'),
                'cameraFile'   : fm.getFilePathByPluginType('CAMERA'),
            }

            # Free anything we have
            if engine.renderer:
                del engine.renderer

            renderer = _vray_for_blender_rt.init(**init)
            if renderer:
                setattr(engine, 'renderer', renderer)
                _vray_for_blender_rt.render(renderer)

    except Exception as e:
        debug.ExceptionInfo(e)
        err = str(e)
    finally:
        exp_init.ShutdownExporter(bus)

    return err