- object_export.separate_tech = True
- res_dir = os.path.join(path, base+"_resources")
- if not os.path.exists(res_dir):
- os.makedirs(res_dir)
- for o in objs:
- obj_out = open_output(os.path.join(res_dir, o.name+".object"))
- progress.push_task(o.name, i/len(objs), (i+1)/len(objs))
- object_export.export(context, obj_out, [o], progress)
- progress.pop_task()
-
- for o in objs:
- out_file.begin("object", '"{}.object"'.format(o.name))
- # XXX Parent relationships screw up the location and rotation
- out_file.write("position", o.location[0], o.location[1], o.location[2])
- if o.rotation_mode=="AXIS_ANGLE":
- angle = o.rotation_axis_angle[0]
- axis = o.rotation_axis_angle[1:]
+ scene_res.write_to_file(out_fn)
+ 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")
+
+ scene_res.statements.append(Statement("type", Token(scene.scene_type.lower())))
+
+ for i in scene.instances:
+ obj_res = resources[i.prototype+".object"]
+ st = scene_res.create_reference_statement("object", obj_res, i.name)
+
+ ss = Statement("transform")
+
+ loc = i.matrix_world.to_translation()
+ ss.sub.append(Statement("position", *tuple(loc)))
+
+ quat = i.matrix_world.to_quaternion()
+ if i.rotation_mode in ('XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX'):
+ angles = [a*180/math.pi for a in quat.to_euler()]
+ ss.sub.append(Statement("euler", *angles));