X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_mesh.py;h=974685b3d1fa8cf0ae579bea292dd7676a8e47a3;hb=fb5f83c2e3f8f8a6a6444a33bec15e9477a487d1;hp=e620b86f22ab9f0ebe155eb8ed50d3bcd9615789;hpb=6e0a6f7a7a406bd22eb4e3f7fc4bf2bdce01d7f9;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_mesh.py b/blender/io_mspgl/export_mesh.py index e620b86f..974685b3 100644 --- a/blender/io_mspgl/export_mesh.py +++ b/blender/io_mspgl/export_mesh.py @@ -1,4 +1,5 @@ import itertools +import os import bpy import mathutils @@ -7,6 +8,7 @@ class MeshExporter: self.show_progress = True self.use_strips = True self.use_degen_tris = False + self.export_all = False def join_strips(self, strips): big_strip = [] @@ -26,17 +28,26 @@ class MeshExporter: return big_strip def export_to_file(self, context, out_fn): - obj = context.active_object + if self.export_all: + objs = [o for o in context.selected_objects if o.type=="MESH"] + else: + objs = [context.active_object] from .util import Progress + path, base = os.path.split(out_fn) + base, ext = os.path.splitext(base) + progress = Progress(self.show_progress and context) - progress.push_task("", 0.0, 0.95) - resource = self.export_mesh(context, obj, progress) + for i, obj in enumerate(objs): + if self.export_all: + out_fn = os.path.join(path, obj.data.name+ext) - with open(out_fn, "w") as out_file: - for s in resource.statements: - s.write_to_file(out_file) + progress.push_task_slice(obj.data.name, i, len(objs)) + resource = self.export_mesh(context, obj, progress) + + resource.write_to_file(out_fn) + progress.pop_task() def export_mesh(self, context, mesh_or_obj, progress): from .mesh import Mesh, create_mesh_from_object @@ -49,7 +60,7 @@ class MeshExporter: progress.pop_task() from .datafile import Resource, Statement, Token - resource = Resource(mesh.name+".mesh") + resource = Resource(mesh.name+".mesh", "mesh") statements = resource.statements st = Statement("vertices", Token("NORMAL3"))