X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_object.py;h=476927af733619b7ed9754ef3f18f71eae593b4a;hb=ef2192e9f19a2c8a2735c3c2ce588e640bea46c4;hp=b39307c8704fd78a74864a4e012ddda990ca44c3;hpb=77b358049bc1ef38ea013175a485cecd71a173c9;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index b39307c8..476927af 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -1,5 +1,4 @@ import os -import mathutils class ObjectExporter: def collect_object_lods(self, obj): @@ -11,7 +10,7 @@ class ObjectExporter: return lods - def export_object_resources(self, context, obj, resources, material_atlases, progress): + def export_object_resources(self, ctx, obj, resources, material_atlases): if material_atlases is None: material_atlases = {} @@ -25,9 +24,10 @@ class ObjectExporter: material_export = MaterialExporter() material_atlas_export = MaterialAtlasExporter() - for i, l in enumerate(lods): + ctx.set_slices(len(lods)) + for l in lods: lod_index = l.lod_index if l.lod_for_parent else 0 - progress.push_task_slice("LOD {}".format(lod_index), i, len(lods)) + task = ctx.next_slice("LOD {}".format(lod_index)) material_atlas = None atlas_flags = [m.render_mode!='EXTERNAL' and m.material_atlas for m in l.data.materials if m] @@ -41,7 +41,7 @@ class ObjectExporter: if material_atlas_key in material_atlases: material_atlas = material_atlases[material_atlas_key] else: - material_atlas = create_material_atlas(context, l.data.materials[0]) + material_atlas = create_material_atlas(task.context, l.data.materials[0]) material_atlases[material_atlas_key] = material_atlas tech_name = "{}.tech".format(material_atlas.name) @@ -50,24 +50,24 @@ class ObjectExporter: resources[tech_name] = material_atlas_export.export_technique(material_atlas, resources) elif l.material_slots and l.material_slots[0].material: material = l.material_slots[0].material + subtask = task.task(material, 0.1) if material.render_mode!='EXTERNAL': tech_name = material.name+".tech" if tech_name not in resources: material = Material(material) - material_export.export_technique_resources(material, resources) + material_export.export_technique_resources(subtask, material, resources) resources[tech_name] = material_export.export_technique(material, resources) elif "stub.tech" not in resources: resources["stub.tech"] = self.export_stub_technique() mesh_name = l.data.name+".mesh" if mesh_name not in resources: - mesh = create_mesh_from_object(context, l, material_atlas, progress) - mesh_res = mesh_export.export_mesh(context, mesh, progress) + subtask = task.task(l.data, 1.0) + mesh = create_mesh_from_object(subtask, l, material_atlas) + mesh_res = mesh_export.export_mesh(subtask, mesh) resources[mesh_name] = mesh_res - progress.pop_task() - - def export_object(self, obj, resources, progress): + def export_object(self, obj, resources): if obj.type!='MESH': raise ValueError("Object {} is not a mesh".format(obj.name)) @@ -119,8 +119,6 @@ class ObjectExporter: else: statements += lod_st - progress.set_progress(1.0) - return obj_res def export_stub_technique(self):