X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_scene.py;h=fa7ca5e538150f3e1df98f2054ddcf8880609385;hb=7ae4af705535271ad84dbfe2b5a24bc9c546ae01;hp=7f4c183aee3fe47011b1b292916e299b86e16e04;hpb=213339d3d269b9bce1edce9561b1ea3e6c2c97e9;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index 7f4c183a..fa7ca5e5 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -7,27 +7,22 @@ class SceneExporter: self.visible_only = True self.collection = True self.skip_existing = True - self.show_progress = True def export_to_file(self, context, out_fn): - from .scene import create_scene_from_current - scene = create_scene_from_current(context, selected_only=self.selected_only, visible_only=self.visible_only) - - path, base = os.path.split(out_fn) - base, ext = os.path.splitext(base) - from .util import Progress - progress = Progress(self.show_progress and context) + progress = Progress(context) - from .export import DataExporter - data_exporter = DataExporter() + from .scene import create_scene_from_current + scene = create_scene_from_current(context, selected_only=self.selected_only, visible_only=self.visible_only) resources = {} - data_exporter.export_resources(context, scene.prototypes, resources, None, progress) + self.export_scene_resources(context, scene, resources, progress) scene_res = self.export_scene(scene, resources) - refs = scene_res.collect_references() progress.set_progress(1.0) + path, base = os.path.split(out_fn) + base, ext = os.path.splitext(base) + if self.collection: existing = None if self.skip_existing: @@ -35,9 +30,15 @@ class SceneExporter: scene_res.write_collection(out_fn, filter=existing) else: scene_res.write_to_file(out_fn) - for r in refs: + for r in scene_res.collect_references(): r.write_to_file(os.path.join(path, r.name)) + def export_scene_resources(self, context, scene, resources, progress): + from .export import DataExporter + data_exporter = DataExporter() + + data_exporter.export_resources(context, scene.prototypes, resources, None, progress) + def export_scene(self, scene, resources): from .datafile import Resource, Statement, Token scene_res = Resource(scene.name+".scene", "scene") @@ -67,3 +68,62 @@ class SceneExporter: scene_res.statements.append(st) return scene_res + + def export_sequence_resources(self, scene, resources): + from .datafile import Resource, Statement, Token + + if scene.background_set: + wrapper_name = scene.name+".wrapper.scene" + if wrapper_name not in resources: + wrapper_res = Resource(wrapper_name, "scene") + wrapper_res.statements.append(Statement("type", Token("ordered"))) + for s in scene.get_chain(): + wrapper_res.statements.append(wrapper_res.create_reference_statement("scene", resources[s.name+".scene"])) + + resources[wrapper_name] = wrapper_res + + lights = [] + s = scene + while s: + lights += s.lights + s = s.background_set + + from .util import make_unique + lights = make_unique(lights) + + from .export_light import LightExporter + light_exporter = LightExporter() + for l in lights: + light_name = l.name+".light" + if light_name not in resources: + resources[light_name] = light_exporter.export_light(l) + + lighting_name = scene.name+".lightn" + if lighting_name not in resources: + lighting_res = Resource(lighting_name, "lighting") + for l in lights: + lighting_res.statements.append(lighting_res.create_reference_statement("light", resources[l.name+".light"])) + + resources[lighting_name] = lighting_res + + def export_sequence(self, scene, resources): + from .datafile import Resource, Statement + seq_res = Resource(scene.name+".seq", "sequence") + + content = scene + if scene.background_set: + content = resources[scene.name+".wrapper.scene"] + + ss = Statement("pass", "", "content") + ss.sub.append(Statement("depth_test", "lequal")) + ss.sub.append(seq_res.create_reference_statement("lighting", resources[scene.name+".lightn"])) + ss.sub.append(seq_res.create_reference_statement("scene", content)) + seq_res.statements.append(ss) + + # Add a colorcurve with linear response to convert into sRGB color space + ss = Statement("colorcurve") + ss.sub.append(Statement("brightness_response", 1.0)) + ss.sub.append(Statement("srgb")) + seq_res.statements.append(ss) + + return seq_res