import os
-import mathutils
class ObjectExporter:
def collect_object_lods(self, obj):
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 = {}
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]
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)
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))
else:
statements += lod_st
- progress.set_progress(1.0)
-
return obj_res
def export_stub_technique(self):