Exemplo n.º 1
0
def save_settings(context):    
    scene = context.scene
    config_updates = {}
    
    jar_path = os.path.abspath(efutil.filesystem_path(scene.sunflow_renderconfigure.sunflowPath))
    if os.path.exists(jar_path):
        config_updates['jar_path'] = jar_path
    else:
        sunflowLog("Unable to find path jar_path")
    
    java_path = os.path.abspath(efutil.filesystem_path(scene.sunflow_renderconfigure.javaPath))
    # if os.path.isdir(java_path) and os.path.exists(java_path):
    if os.path.exists(java_path):
        config_updates['java_path'] = java_path
    else:
        sunflowLog("Unable to find path java_path")
        
    
    memoryalloc = scene.sunflow_renderconfigure.memoryAllocated
    config_updates['memoryalloc'] = memoryalloc
    
        
    try:
        for k, v in config_updates.items():
            efutil.write_config_value('sunflow', 'defaults', k, v)
            sunflowLog("writing values")
    except Exception as err:
        sunflowLog('WARNING: Saving sunflow configuration failed, please set your user scripts dir: %s' % err)
Exemplo n.º 2
0
def save_settings(context):
    scene = context.scene
    config_updates = {}

    jar_path = os.path.abspath(
        efutil.filesystem_path(scene.sunflow_renderconfigure.sunflowPath))
    if os.path.exists(jar_path):
        config_updates['jar_path'] = jar_path
    else:
        sunflowLog("Unable to find path jar_path")

    java_path = os.path.abspath(
        efutil.filesystem_path(scene.sunflow_renderconfigure.javaPath))
    # if os.path.isdir(java_path) and os.path.exists(java_path):
    if os.path.exists(java_path):
        config_updates['java_path'] = java_path
    else:
        sunflowLog("Unable to find path java_path")

    memoryalloc = scene.sunflow_renderconfigure.memoryAllocated
    config_updates['memoryalloc'] = memoryalloc

    try:
        for k, v in config_updates.items():
            efutil.write_config_value('sunflow', 'defaults', k, v)
            sunflowLog("writing values")
    except Exception as err:
        sunflowLog(
            'WARNING: Saving sunflow configuration failed, please set your user scripts dir: %s'
            % err)
Exemplo n.º 3
0
    def set_selection_overriden(self, context):
        from .selectOperator import add_shortkeys, remove_shortkeys
        if context:
            add_shortkeys()
        else:
            remove_shortkeys()

        if bpy.context.user_preferences.inputs.select_mouse == 'RIGHT':
            bpy.bls_selection_override_right = context
            efutil.write_config_value(bl_info['name'], 'defaults',
                                      'selection_override_right', context)
        else:
            bpy.bls_selection_override_left = context
            efutil.write_config_value(bl_info['name'], 'defaults',
                                      'selection_override_left', context)
Exemplo n.º 4
0
	def draw(self, context):
		if not hasattr(context, 'material'):
			return
		self.layout.template_preview(context.material, show_buttons=False)
		engine = context.scene.mitsuba_engine
		row = self.layout.row(True)
		row.prop(engine, "preview_depth")
		row.prop(engine, "preview_spp")
		
		global cached_depth
		global cached_spp
		if engine.preview_depth != cached_depth or engine.preview_spp != cached_spp:
			actualChange = cached_depth != None
			cached_depth = engine.preview_depth
			cached_spp = engine.preview_spp
			if actualChange:
				MtsLog("Forcing a repaint")
				efutil.write_config_value('mitsuba', 'defaults', 'preview_spp', str(cached_spp))
				efutil.write_config_value('mitsuba', 'defaults', 'preview_depth', str(cached_depth))
Exemplo n.º 5
0
    def draw(self, context):
        if not hasattr(context, 'material'):
            return
        self.layout.template_preview(context.material, show_buttons=False)
        engine = context.scene.mitsuba_engine
        row = self.layout.row(True)
        row.prop(engine, "preview_depth")
        row.prop(engine, "preview_spp")

        global cached_depth
        global cached_spp
        if engine.preview_depth != cached_depth or engine.preview_spp != cached_spp:
            actualChange = cached_depth != None
            cached_depth = engine.preview_depth
            cached_spp = engine.preview_spp
            if actualChange:
                MtsLog("Forcing a repaint")
                efutil.write_config_value('mitsuba', 'defaults', 'preview_spp',
                                          str(cached_spp))
                efutil.write_config_value('mitsuba', 'defaults',
                                          'preview_depth', str(cached_depth))
Exemplo n.º 6
0
    def render(self, context):
        '''
        Render the scene file, or in our case, export the frame(s)
        and launch an Indigo process.
        '''

        with RENDERENGINE_indigo.render_lock:  # Just render one thing at a time.
            self.renderer = None
            self.message_thread = None
            self.stats_thread = None
            self.framebuffer_thread = None
            self.render_update_timer = None
            self.rendering = False

            # force scene update to current rendering frame
            # Not sure why - Yves
            #context.frame_set(context.frame_current)

            #------------------------------------------------------------------------------
            # Export the Scene

            # Get the frame path.
            frame_path = efutil.filesystem_path(context.render.frame_path())

            # Get the filename for the frame sans extension.
            image_out_path = os.path.splitext(frame_path)[0]

            # Generate the name for the scene file(s).
            if context.indigo_engine.use_output_path == True:
                # Get the output path from the frame path.
                output_path = os.path.dirname(frame_path)

                # Generate the output filename
                output_filename = '%s.%s.%05i.igs' % (
                    efutil.scene_filename(), bpy.path.clean_name(
                        context.name), context.frame_current)
            else:
                # Get export path from the indigo_engine.
                export_path = efutil.filesystem_path(
                    context.indigo_engine.export_path)

                # Get the directory name from the output path.
                output_path = os.path.dirname(export_path)

                # Get the filename from the output path and remove the extension.
                output_filename = os.path.splitext(
                    os.path.basename(export_path))[0]

                # Count contiguous # chars and replace them with the frame number.
                # If the hash count is 0 and we are exporting an animation, append the frame numbers.
                hash_count = util.count_contiguous('#', output_filename)
                if hash_count != 0:
                    output_filename = output_filename.replace(
                        '#' * hash_count,
                        ('%%0%0ii' % hash_count) % context.frame_current)
                elif self.is_animation:
                    output_filename = output_filename + (
                        '%%0%0ii' % 4) % context.frame_current

                # Add .igs extension.
                output_filename += '.igs'

            # The full path of the exported scene file.
            exported_file = '/'.join([output_path, output_filename])

            # Create output_path if it does not exist.
            if not os.path.exists(output_path):
                os.makedirs(output_path)

            # If an animation is rendered, write an indigo queue file (.igq).
            if self.is_animation:
                igq_filename = '%s/%s.%s.igq' % (
                    output_path, efutil.scene_filename(),
                    bpy.path.clean_name(context.name))

                if context.frame_current == context.frame_start:
                    # Start a new igq file.
                    igq_file = open(igq_filename, 'w')
                    igq_file.write(
                        '<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n'
                    )
                    igq_file.write('<render_queue>\n')
                else:
                    # Append to existing igq.
                    igq_file = open(igq_filename, 'a')

                rnd = random.Random()
                rnd.seed(context.frame_current)

                # Write igq item.
                igq_file.write('\t<item>\n')
                igq_file.write('\t\t<scene_path>%s</scene_path>\n' %
                               exported_file)
                igq_file.write('\t\t<halt_time>%d</halt_time>\n' %
                               context.indigo_engine.halttime)
                igq_file.write('\t\t<halt_spp>%d</halt_spp>\n' %
                               context.indigo_engine.haltspp)
                igq_file.write('\t\t<output_path>%s</output_path>\n' %
                               image_out_path)
                igq_file.write('\t\t<seed>%s</seed>\n' %
                               rnd.randint(1, 1000000))
                igq_file.write('\t</item>\n')

                # If this is the last frame, write the closing tag.
                if context.frame_current == context.frame_end:
                    igq_file.write('</render_queue>\n')

                igq_file.close()

                # Calculate the progress by frame with frame range (fr) and frame offset (fo).
                fr = context.frame_end - context.frame_start
                fo = context.frame_current - context.frame_start
                self.update_progress(fo / fr)

            scene_writer = indigo.operators._Impl_OT_indigo(
                directory=output_path,
                filename=output_filename).set_report(self.report)

            # Write the scene file.
            export_result = scene_writer.execute(context)

            # Return if the export didn't finish.
            if not 'FINISHED' in export_result:
                return

            #------------------------------------------------------------------------------
            # Update indigo defaults config file .
            config_updates = {
                'auto_start': context.indigo_engine.auto_start,
                'console_output': context.indigo_engine.console_output
            }

            if context.indigo_engine.use_console:
                indigo_path = getConsolePath(context)
            else:
                indigo_path = getGuiPath(context)

            if os.path.exists(indigo_path):
                config_updates['install_path'] = getInstallPath(context)

            try:
                for k, v in config_updates.items():
                    efutil.write_config_value('indigo', 'defaults', k, v)
            except Exception as err:
                indigo_log('Saving indigo config failed: %s' % err,
                           message_type='ERROR')

            # Make sure that the Indigo we are going to launch is at least as
            # new as the exporter version.
            version_ok = True
            if not context.indigo_engine.skip_version_check:
                iv = getVersion(context)
                for i in range(3):
                    version_ok &= iv[i] >= bl_info['version'][i]

            #------------------------------------------------------------------------------
            # Conditionally Spawn Indigo.
            if context.indigo_engine.auto_start:

                exe_path = efutil.filesystem_path(indigo_path)

                if not os.path.exists(exe_path):
                    print("Failed to find indigo at '" + str(exe_path) + "'")
                    msg = "Failed to find indigo at '" + str(exe_path) + "'."
                    msg + "\n  "
                    msg += "Please make sure you have Indigo installed, and that the path to indigo in the 'Indigo Render Engine Settings' is set correctly."
                    self.report({'ERROR'}, msg)

                #if not version_ok:
                #indigo_log("Unsupported version v%s; Cannot start Indigo with this scene" % ('.'.join(['%s'%i for i in iv])), message_type='ERROR')
                #return

                # if it's an animation, don't execute until final frame
                if self.is_animation and context.frame_current != context.frame_end:
                    return

                # if animation and final frame, launch queue instead of single frame
                if self.is_animation and context.frame_current == context.frame_end:
                    exported_file = igq_filename
                    indigo_args = [exe_path, exported_file]
                else:
                    indigo_args = [
                        exe_path, exported_file, '-o', image_out_path + '.png'
                    ]

                # Set master or working master command line args.
                if context.indigo_engine.network_mode == 'master':
                    indigo_args.extend(['-n', 'm'])
                elif context.indigo_engine.network_mode == 'working_master':
                    indigo_args.extend(['-n', 'wm'])

                # Set port arg if network rendering is enabled.
                if context.indigo_engine.network_mode in [
                        'master', 'working_master'
                ]:
                    indigo_args.extend(
                        ['-p', '%i' % context.indigo_engine.network_port])

                # Set hostname and port arg.
                if context.indigo_engine.network_mode == 'manual':
                    indigo_args.extend([
                        '-h',
                        '%s:%i' % (context.indigo_engine.network_host,
                                   context.indigo_engine.network_port)
                    ])

                # indigo_log("Starting indigo: %s" % indigo_args)

                # If we're starting a console or should wait for the process, listen to the output.
                if context.indigo_engine.use_console or context.indigo_engine.wait_for_process:
                    f_stdout = subprocess.PIPE
                else:
                    f_stdout = None

                # Launch the Indigo process.
                indigo_proc = subprocess.Popen(indigo_args, stdout=f_stdout)
                indigo_pid = indigo_proc.pid
                indigo_log('Started Indigo process, PID: %i' % indigo_pid)

                # Wait for the render to finish if we use the console or should wait for the process.
                if context.indigo_engine.use_console or context.indigo_engine.wait_for_process:
                    while indigo_proc.poll() == None:
                        indigo_proc.communicate()
                        time.sleep(2)

                    indigo_proc.wait()
                    if not indigo_proc.stdout.closed:
                        indigo_proc.communicate()
                    if indigo_proc.returncode == -1:
                        sys.exit(-1)

            else:
                indigo_log("Scene was exported to %s" % exported_file)

            #------------------------------------------------------------------------------
            # Finished
            return
Exemplo n.º 7
0
	def get_process_args(self, scene, start_rendering):
		config_updates = {
			'auto_start': start_rendering
		}
		
		addon_prefs = LuxRenderAddon.get_prefs()
		luxrender_path = efutil.filesystem_path( addon_prefs.install_path )
		
		print('luxrender_path: ', luxrender_path)
		
		if luxrender_path == '':
			return ['']
		
		if luxrender_path[-1] != '/':
			luxrender_path += '/'
		
		if sys.platform == 'darwin':
			luxrender_path += 'LuxRender.app/Contents/MacOS/%s' % scene.luxrender_engine.binary_name # Get binary from OSX bundle
			if not os.path.exists(luxrender_path):
				LuxLog('LuxRender not found at path: %s' % luxrender_path, ', trying default LuxRender location')
				luxrender_path = '/Applications/LuxRender/LuxRender.app/Contents/MacOS/%s' % scene.luxrender_engine.binary_name # try fallback to default installation path

		elif sys.platform == 'win32':
			luxrender_path += '%s.exe' % scene.luxrender_engine.binary_name
		else:
			luxrender_path += scene.luxrender_engine.binary_name
		
		if not os.path.exists(luxrender_path):
			raise Exception('LuxRender not found at path: %s' % luxrender_path)
		
		cmd_args = [luxrender_path]
		
		# set log verbosity
		if scene.luxrender_engine.log_verbosity != 'default':
			cmd_args.append('--' + scene.luxrender_engine.log_verbosity)
		
		if scene.luxrender_engine.binary_name == 'luxrender':
			# Copy the GUI log to the console
			cmd_args.append('--logconsole')
		
		# Set number of threads for external processes
		if not scene.luxrender_engine.threads_auto:
			cmd_args.append('--threads=%i' % scene.luxrender_engine.threads)
			
		#Set fixed seeds, if enabled
		if scene.luxrender_engine.fixed_seed:
			cmd_args.append('--fixedseed')
		
		if scene.luxrender_networking.use_network_servers and scene.luxrender_networking.servers != '':
			for server in scene.luxrender_networking.servers.split(','):
				cmd_args.append('--useserver')
				cmd_args.append(server.strip())
			
			cmd_args.append('--serverinterval')
			cmd_args.append('%i' % scene.luxrender_networking.serverinterval)
			
			config_updates['servers'] = scene.luxrender_networking.servers
			config_updates['serverinterval'] = '%i' % scene.luxrender_networking.serverinterval
		
		config_updates['use_network_servers'] = scene.luxrender_networking.use_network_servers
		
		# Save changed config items and then launch Lux
		
		try:
			for k, v in config_updates.items():
				efutil.write_config_value('luxrender', 'defaults', k, v)
		except Exception as err:
			LuxLog('WARNING: Saving LuxRender config failed, please set your user scripts dir: %s' % err)
		
		return cmd_args
Exemplo n.º 8
0
	def render(self, scene):
		if self is None or scene is None:
			MtsLog('ERROR: Scene is missing!')
			return
		if scene.mitsuba_engine.binary_path == '':
			MtsLog('ERROR: The binary path is unspecified!')
			return
		
		with self.render_lock:	# just render one thing at a time
			if scene.name == 'preview':
				self.render_preview(scene)
				return
			
			config_updates = {}
			binary_path = os.path.abspath(efutil.filesystem_path(scene.mitsuba_engine.binary_path))
			if os.path.isdir(binary_path) and os.path.exists(binary_path):
				config_updates['binary_path'] = binary_path
			
			try:
				for k, v in config_updates.items():
					efutil.write_config_value('mitsuba', 'defaults', k, v)
			except Exception as err:
				MtsLog('WARNING: Saving Mitsuba configuration failed, please set your user scripts dir: %s' % err)
			
			scene_path = efutil.filesystem_path(scene.render.filepath)
			if os.path.isdir(scene_path):
				output_dir = scene_path
			else:
				output_dir = os.path.dirname(scene_path)		
			
			MtsLog('MtsBlend: Current directory = "%s"' % output_dir)
			output_basename = efutil.scene_filename() + '.%s.%05i' % (scene.name, scene.frame_current)
			
			result = SceneExporter(
				directory = output_dir,
				filename = output_basename,
			).export(scene)
			
			if not result:
				MtsLog('Error while exporting -- check the console for details.')
				return
			
			if scene.mitsuba_engine.export_mode == 'render':
				
				MtsLog("MtsBlend: Launching renderer ..")
				if scene.mitsuba_engine.render_mode == 'gui':
					MtsLaunch(scene.mitsuba_engine.binary_path, output_dir,
						['mtsgui', efutil.export_path])
				elif scene.mitsuba_engine.render_mode == 'cli':
					output_file = efutil.export_path[:-4] + "." + scene.camera.data.mitsuba_film.fileExtension
					mitsuba_process = MtsLaunch(scene.mitsuba_engine.binary_path, output_dir,
						['mitsuba', '-r', str(scene.mitsuba_engine.refresh_interval),
							'-o', output_file, efutil.export_path]
					)
					framebuffer_thread = MtsFilmDisplay()
					framebuffer_thread.set_kick_period(scene.mitsuba_engine.refresh_interval) 
					framebuffer_thread.begin(self, output_file, resolution(scene))
					render_update_timer = None
					while mitsuba_process.poll() == None and not self.test_break():
						render_update_timer = threading.Timer(1, self.process_wait_timer)
						render_update_timer.start()
						if render_update_timer.isAlive(): render_update_timer.join()
					
					# If we exit the wait loop (user cancelled) and mitsuba is still running, then send SIGINT
					if mitsuba_process.poll() == None:
						# Use SIGTERM because that's the only one supported on Windows
						mitsuba_process.send_signal(subprocess.signal.SIGTERM)
					
					# Stop updating the render result and load the final image
					framebuffer_thread.stop()
					framebuffer_thread.join()
					
					if mitsuba_process.poll() != None and mitsuba_process.returncode != 0:
						MtsLog("MtsBlend: Rendering failed -- check the console")
					else:
						framebuffer_thread.kick(render_end=True)
					framebuffer_thread.shutdown()
Exemplo n.º 9
0
    def render(self, scene):
        if self is None or scene is None:
            MtsLog('ERROR: Scene is missing!')
            return
        if scene.mitsuba_engine.binary_path == '':
            MtsLog('ERROR: The binary path is unspecified!')
            return

        with self.render_lock:  # just render one thing at a time
            if scene.name == 'preview':
                self.render_preview(scene)
                return

            config_updates = {}
            binary_path = os.path.abspath(
                efutil.filesystem_path(scene.mitsuba_engine.binary_path))
            if os.path.isdir(binary_path) and os.path.exists(binary_path):
                config_updates['binary_path'] = binary_path

            try:
                for k, v in config_updates.items():
                    efutil.write_config_value('mitsuba', 'defaults', k, v)
            except Exception as err:
                MtsLog(
                    'WARNING: Saving Mitsuba configuration failed, please set your user scripts dir: %s'
                    % err)

            scene_path = efutil.filesystem_path(scene.render.filepath)
            if os.path.isdir(scene_path):
                output_dir = scene_path
            else:
                output_dir = os.path.dirname(scene_path)

            MtsLog('MtsBlend: Current directory = "%s"' % output_dir)
            output_basename = efutil.scene_filename() + '.%s.%05i' % (
                scene.name, scene.frame_current)

            result = SceneExporter(
                directory=output_dir,
                filename=output_basename,
            ).export(scene)

            if not result:
                MtsLog(
                    'Error while exporting -- check the console for details.')
                return

            if scene.mitsuba_engine.export_mode == 'render':

                MtsLog("MtsBlend: Launching renderer ..")
                if scene.mitsuba_engine.render_mode == 'gui':
                    MtsLaunch(scene.mitsuba_engine.binary_path, output_dir,
                              ['mtsgui', efutil.export_path])
                elif scene.mitsuba_engine.render_mode == 'cli':
                    output_file = efutil.export_path[:
                                                     -4] + "." + scene.camera.data.mitsuba_film.fileExtension
                    mitsuba_process = MtsLaunch(
                        scene.mitsuba_engine.binary_path, output_dir, [
                            'mitsuba', '-r',
                            str(scene.mitsuba_engine.refresh_interval), '-o',
                            output_file, efutil.export_path
                        ])
                    framebuffer_thread = MtsFilmDisplay()
                    framebuffer_thread.set_kick_period(
                        scene.mitsuba_engine.refresh_interval)
                    framebuffer_thread.begin(self, output_file,
                                             resolution(scene))
                    render_update_timer = None
                    while mitsuba_process.poll(
                    ) == None and not self.test_break():
                        render_update_timer = threading.Timer(
                            1, self.process_wait_timer)
                        render_update_timer.start()
                        if render_update_timer.isAlive():
                            render_update_timer.join()

                    # If we exit the wait loop (user cancelled) and mitsuba is still running, then send SIGINT
                    if mitsuba_process.poll() == None:
                        # Use SIGTERM because that's the only one supported on Windows
                        mitsuba_process.send_signal(subprocess.signal.SIGTERM)

                    # Stop updating the render result and load the final image
                    framebuffer_thread.stop()
                    framebuffer_thread.join()

                    if mitsuba_process.poll(
                    ) != None and mitsuba_process.returncode != 0:
                        MtsLog(
                            "MtsBlend: Rendering failed -- check the console")
                    else:
                        framebuffer_thread.kick(render_end=True)
                    framebuffer_thread.shutdown()
Exemplo n.º 10
0
    def render(self, context):
        '''
        Render the scene file, or in our case, export the frame(s)
        and launch an Indigo process.
        '''

        with RENDERENGINE_indigo.render_lock:    # Just render one thing at a time.
            self.renderer            = None
            self.message_thread      = None
            self.stats_thread        = None
            self.framebuffer_thread  = None
            self.render_update_timer = None
            self.rendering           = False

            # force scene update to current rendering frame
            # Not sure why - Yves
            #context.frame_set(context.frame_current)

            #------------------------------------------------------------------------------
            # Export the Scene

            # Get the frame path.
            frame_path = efutil.filesystem_path(context.render.frame_path())

            # Get the filename for the frame sans extension.
            image_out_path = os.path.splitext(frame_path)[0]

            # Generate the name for the scene file(s).
            if context.indigo_engine.use_output_path == True:
                # Get the output path from the frame path.
                output_path = os.path.dirname(frame_path)

                # Generate the output filename
                output_filename = '%s.%s.%05i.igs' % (efutil.scene_filename(), bpy.path.clean_name(context.name), context.frame_current)
            else:
                # Get export path from the indigo_engine.
                export_path = efutil.filesystem_path(context.indigo_engine.export_path)

                # Get the directory name from the output path.
                output_path = os.path.dirname(export_path)

                # Get the filename from the output path and remove the extension.
                output_filename = os.path.splitext(os.path.basename(export_path))[0]

                # Count contiguous # chars and replace them with the frame number.
                # If the hash count is 0 and we are exporting an animation, append the frame numbers.
                hash_count = util.count_contiguous('#', output_filename)
                if hash_count != 0:
                    output_filename = output_filename.replace('#'*hash_count, ('%%0%0ii'%hash_count)%context.frame_current)
                elif self.is_animation:
                    output_filename = output_filename + ('%%0%0ii'%4)%context.frame_current

                # Add .igs extension.
                output_filename += '.igs'


            # The full path of the exported scene file.
            exported_file = '/'.join([
                output_path,
                output_filename
            ])

            # Create output_path if it does not exist.
            if not os.path.exists(output_path):
                os.makedirs(output_path)

            # If an animation is rendered, write an indigo queue file (.igq).
            if self.is_animation:
                igq_filename = '%s/%s.%s.igq'%(output_path, efutil.scene_filename(), bpy.path.clean_name(context.name))

                if context.frame_current == context.frame_start:
                    # Start a new igq file.
                    igq_file = open(igq_filename, 'w')
                    igq_file.write('<?xml version="1.0" encoding="utf-8" standalone="no" ?>\n')
                    igq_file.write('<render_queue>\n')
                else:
                    # Append to existing igq.
                    igq_file = open(igq_filename, 'a')
                    
                rnd = random.Random()
                rnd.seed(context.frame_current)

                # Write igq item.
                igq_file.write('\t<item>\n')
                igq_file.write('\t\t<scene_path>%s</scene_path>\n' % exported_file)
                igq_file.write('\t\t<halt_time>%d</halt_time>\n' % context.indigo_engine.halttime)
                igq_file.write('\t\t<halt_spp>%d</halt_spp>\n' % context.indigo_engine.haltspp)
                igq_file.write('\t\t<output_path>%s</output_path>\n' % image_out_path)
                igq_file.write('\t\t<seed>%s</seed>\n' % rnd.randint(1, 1000000))
                igq_file.write('\t</item>\n')

                # If this is the last frame, write the closing tag.
                if context.frame_current == context.frame_end:
                    igq_file.write('</render_queue>\n')

                igq_file.close()

                # Calculate the progress by frame with frame range (fr) and frame offset (fo).
                fr = context.frame_end - context.frame_start
                fo = context.frame_current - context.frame_start
                self.update_progress(fo/fr)

            scene_writer = indigo.operators._Impl_OT_indigo(
                directory = output_path,
                filename = output_filename
            ).set_report(self.report)

            # Write the scene file.
            export_result = scene_writer.execute(context)

            # Return if the export didn't finish.
            if not 'FINISHED' in export_result:
                return

            #------------------------------------------------------------------------------
            # Update indigo defaults config file .
            config_updates = {
                'auto_start': context.indigo_engine.auto_start,
                'console_output': context.indigo_engine.console_output
            }

            if context.indigo_engine.use_console:
                indigo_path = getConsolePath(context)
            else:
                indigo_path = getGuiPath(context)

            if os.path.exists(indigo_path):
                config_updates['install_path'] = getInstallPath(context)

            try:
                for k,v in config_updates.items():
                    efutil.write_config_value('indigo', 'defaults', k, v)
            except Exception as err:
                indigo_log('Saving indigo config failed: %s' % err, message_type='ERROR')

            # Make sure that the Indigo we are going to launch is at least as
            # new as the exporter version.
            version_ok = True
            if not context.indigo_engine.skip_version_check:
                iv = getVersion(context)
                for i in range(3):
                    version_ok &= iv[i]>=bl_info['version'][i]

            #------------------------------------------------------------------------------
            # Conditionally Spawn Indigo.
            if context.indigo_engine.auto_start:

                exe_path = efutil.filesystem_path( indigo_path )

                if not os.path.exists(exe_path):
                    print("Failed to find indigo at '" + str(exe_path) + "'")
                    msg = "Failed to find indigo at '" + str(exe_path) + "'."
                    msg + "\n  "
                    msg += "Please make sure you have Indigo installed, and that the path to indigo in the 'Indigo Render Engine Settings' is set correctly."
                    self.report({'ERROR'}, msg)

                #if not version_ok:
                    #indigo_log("Unsupported version v%s; Cannot start Indigo with this scene" % ('.'.join(['%s'%i for i in iv])), message_type='ERROR')
                    #return

                # if it's an animation, don't execute until final frame
                if self.is_animation and context.frame_current != context.frame_end:
                    return

                # if animation and final frame, launch queue instead of single frame
                if self.is_animation and context.frame_current == context.frame_end:
                    exported_file = igq_filename
                    indigo_args = [
                        exe_path,
                        exported_file
                    ]
                else:
                    indigo_args = [
                        exe_path,
                        exported_file,
                        '-o',
                        image_out_path + '.png'
                    ]

                # Set master or working master command line args.
                if context.indigo_engine.network_mode == 'master':
                    indigo_args.extend(['-n', 'm'])
                elif context.indigo_engine.network_mode == 'working_master':
                    indigo_args.extend(['-n', 'wm'])

                # Set port arg if network rendering is enabled.
                if context.indigo_engine.network_mode in ['master', 'working_master']:
                    indigo_args.extend([
                        '-p',
                        '%i' % context.indigo_engine.network_port
                    ])

                # Set hostname and port arg.
                if context.indigo_engine.network_mode == 'manual':
                    indigo_args.extend([
                        '-h',
                        '%s:%i' % (context.indigo_engine.network_host, context.indigo_engine.network_port)
                ])

                # indigo_log("Starting indigo: %s" % indigo_args)

                # If we're starting a console or should wait for the process, listen to the output.
                if context.indigo_engine.use_console or context.indigo_engine.wait_for_process:
                    f_stdout = subprocess.PIPE
                else:
                    f_stdout = None

                # Launch the Indigo process.
                indigo_proc = subprocess.Popen(indigo_args, stdout=f_stdout)
                indigo_pid = indigo_proc.pid
                indigo_log('Started Indigo process, PID: %i' % indigo_pid)

                # Wait for the render to finish if we use the console or should wait for the process.
                if context.indigo_engine.use_console or context.indigo_engine.wait_for_process:
                    while indigo_proc.poll() == None:
                        indigo_proc.communicate()
                        time.sleep(2)

                    indigo_proc.wait()
                    if not indigo_proc.stdout.closed:
                        indigo_proc.communicate()
                    if indigo_proc.returncode == -1:
                        sys.exit(-1)

            else:
                indigo_log("Scene was exported to %s" % exported_file)

            #------------------------------------------------------------------------------
            # Finished
            return
Exemplo n.º 11
0
def set_export_console_output(self, context):
    export.PRINT_CONSOLE = self.console_output
    write_config_value(getAddonDir(), 'defaults', 'console_output',
                       self.console_output)
Exemplo n.º 12
0
    def get_process_args(self, scene, start_rendering):
        config_updates = {'auto_start': start_rendering}

        addon_prefs = LuxRenderAddon.get_prefs()
        luxrender_path = efutil.filesystem_path(addon_prefs.install_path)

        print('luxrender_path: ', luxrender_path)

        if luxrender_path == '':
            return ['']

        if luxrender_path[-1] != '/':
            luxrender_path += '/'

        if sys.platform == 'darwin':
            luxrender_path += 'LuxRender.app/Contents/MacOS/%s' % scene.luxrender_engine.binary_name  # Get binary from OSX bundle
            if not os.path.exists(luxrender_path):
                LuxLog('LuxRender not found at path: %s' % luxrender_path,
                       ', trying default LuxRender location')
                luxrender_path = '/Applications/LuxRender/LuxRender.app/Contents/MacOS/%s' % scene.luxrender_engine.binary_name  # try fallback to default installation path

        elif sys.platform == 'win32':
            luxrender_path += '%s.exe' % scene.luxrender_engine.binary_name
        else:
            luxrender_path += scene.luxrender_engine.binary_name

        if not os.path.exists(luxrender_path):
            raise Exception('LuxRender not found at path: %s' % luxrender_path)

        cmd_args = [luxrender_path]

        # set log verbosity
        if scene.luxrender_engine.log_verbosity != 'default':
            cmd_args.append('--' + scene.luxrender_engine.log_verbosity)

        if scene.luxrender_engine.binary_name == 'luxrender':
            # Copy the GUI log to the console
            cmd_args.append('--logconsole')

        # Set number of threads for external processes
        if not scene.luxrender_engine.threads_auto:
            cmd_args.append('--threads=%i' % scene.luxrender_engine.threads)

        #Set fixed seeds, if enabled
        if scene.luxrender_engine.fixed_seed:
            cmd_args.append('--fixedseed')

        if scene.luxrender_networking.use_network_servers and scene.luxrender_networking.servers != '':
            for server in scene.luxrender_networking.servers.split(','):
                cmd_args.append('--useserver')
                cmd_args.append(server.strip())

            cmd_args.append('--serverinterval')
            cmd_args.append('%i' % scene.luxrender_networking.serverinterval)

            config_updates['servers'] = scene.luxrender_networking.servers
            config_updates[
                'serverinterval'] = '%i' % scene.luxrender_networking.serverinterval

        config_updates[
            'use_network_servers'] = scene.luxrender_networking.use_network_servers

        # Save changed config items and then launch Lux

        try:
            for k, v in config_updates.items():
                efutil.write_config_value('luxrender', 'defaults', k, v)
        except Exception as err:
            LuxLog(
                'WARNING: Saving LuxRender config failed, please set your user scripts dir: %s'
                % err)

        return cmd_args
Exemplo n.º 13
0
 def set_export_console_output(self, context):
     indigo.export.PRINT_CONSOLE = self.console_output
     efutil.write_config_value('indigo', 'defaults', 'console_output',
                               self.console_output)
Exemplo n.º 14
0
 def set_export_console_output(self, context):
     indigo.export.PRINT_CONSOLE = self.console_output
     efutil.write_config_value('indigo', 'defaults', 'console_output', self.console_output)