if s.camera:
all_objects.append(s.camera)
+ scene_queue = list(scenes.values())
+ ordered_scenes = []
+ while scene_queue:
+ s = scene_queue.pop(0)
+ if not s.background_set or s.background_set in ordered_scenes:
+ ordered_scenes.append(s)
+ else:
+ scene_queue.append(s)
+
from .util import make_unique
all_objects = make_unique(all_objects)
resources = {}
dummy_res = data_exporter.export_resources(context, all_objects, resources, None, progress)
- for s in scenes.values():
+ for s in ordered_scenes:
scene_name = s.name+".scene"
if scene_name not in resources:
scene_res = scene_exporter.export_scene(s, resources)
from .datafile import Resource, Statement, Token
scene_res = Resource(scene.name+".scene", "scene")
- scene_res.statements.append(Statement("type", Token("simple")))
+ if scene.background_set:
+ scene_res.statements.append(Statement("type", Token("ordered")))
+ if scene.background_set:
+ scene_res.statements.append(scene_res.create_reference_statement("scene", resources[scene.background_set.name+".scene"]))
+
+ st = Statement("scene")
+ st.sub.append(Statement("type", Token("simple")))
+ self.add_instances(scene_res, st.sub, scene.instances, resources)
+ scene_res.statements.append(st)
+ else:
+ scene_res.statements.append(Statement("type", Token("simple")))
+
+ self.add_instances(scene_res, scene_res.statements, scene.instances, resources)
+
+ return scene_res
+
+ def add_instances(self, scene_res, statements, instances, resources):
+ from .datafile import Statement
- for i in scene.instances:
+ for i in instances:
obj_res = resources[i.prototype+".object"]
st = scene_res.create_reference_statement("object", obj_res, i.name)
ss.sub.append(Statement("scale", *tuple(scale)))
st.sub.append(ss)
- scene_res.statements.append(st)
-
- return scene_res
+ statements.append(st)
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:
if scene.use_hdr:
seq_res.statements.append(Statement("hdr", True))
- content = scene
- if scene.background_set:
- content = resources[scene.name+".wrapper.scene"]
-
ss = Statement("clear")
ss.sub.append(Statement("color", 0.0, 0.0, 0.0, 0.0))
ss.sub.append(Statement("depth", 1.0))
ss = Statement("step", "", "content")
ss.sub.append(Statement("depth_test", Token("LEQUAL")))
ss.sub.append(seq_res.create_reference_statement("lighting", resources[scene.name+".lightn"]))
- ss.sub.append(seq_res.create_reference_statement("scene", content))
+ ss.sub.append(seq_res.create_reference_statement("scene", resources[scene.name+".scene"]))
seq_res.statements.append(ss)
if scene.use_ao: