X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_scene.py;h=a3f0a4e44a5823eae380acac69b9b9d9bc78f4d4;hb=42ae18b7a9dc13a72bf421e564f02829d4bdd5be;hp=cb623a1587f8fc14a0b15fe41c4eb30d4b3d6a4b;hpb=736a076cf12aca02492eae6c77eff846bde0cdda;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_scene.py b/blender/io_mspgl/export_scene.py index cb623a15..a3f0a4e4 100644 --- a/blender/io_mspgl/export_scene.py +++ b/blender/io_mspgl/export_scene.py @@ -74,32 +74,18 @@ class SceneExporter: refs = scene_res.collect_references() if self.resource_collection: - from .datafile import Statement - keywords = { ".mat": "material", - ".mesh": "mesh", - ".object": "object", - ".tech": "technique", - ".tex2d": "texture2d" } - with open(os.path.join(path, base+"_resources.mdc"), "w") as res_out: - for r in refs: - if self.skip_existing and os.path.exists(os.path.join(path, r.name)): - continue - - st = Statement(keywords[os.path.splitext(r.name)[1]], r.name) - st.sub = r.statements - st.write_to_file(res_out) + filter = None + if self.skip_existing: + filter = lambda r: not os.path.exists(os.path.join(path, r.name)) + scene_res.write_collection(os.path.join(path, base+"_resources.mdc"), exclude=self=True, filter) else: res_dir = os.path.join(path, base+"_resources") if not os.path.exists(res_dir): os.makedirs(res_dir) for r in refs: - with open(os.path.join(res_dir, r.name), "w") as res_out: - for s in r.statements: - s.write_to_file(res_out) + r.write_to_file(os.path.join(res_dir, r.name)) - with open(out_fn, "w") as out_file: - for s in scene_res.statements: - s.write_to_file(out_file) + scene_res.write_to_file(out_fn) def export_scene_resources(self, context, objs, resources, progress): from .export_object import ObjectExporter @@ -117,7 +103,7 @@ class SceneExporter: def export_scene(self, context, objs, progress, *, prototypes, resources): from .datafile import Resource, Statement - scene_res = Resource("scene.scene") + scene_res = Resource("scene.scene", "scene") for o in objs: obj_res = resources[prototypes[o.name].name+".object"]