- # TODO Export techniques as separate items in the collection
- for i, o in enumerate(unique_objects):
- res_out.begin("object", '"{}.object"'.format(o.name))
- progress.push_task_slice(o.name, i, len(objs))
- object_export.export(context, res_out, o, progress)
- progress.pop_task()
- res_out.end()
- else:
- object_export.separate_mesh = True
- 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 i, o in enumerate(unique_objects):
- obj_out = open_output(os.path.join(res_dir, o.name+".object"))
- progress.push_task_slice(o.name, i, len(objs))
- object_export.export(context, obj_out, o, progress)
- progress.pop_task()
-
- for o in objs:
- out_file.begin("object", '"{}.object"'.format(object_prototypes[o.name].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.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));