X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_object.py;h=989d675837485f121459d9bd130f3f4e6035e320;hp=476927af733619b7ed9754ef3f18f71eae593b4a;hb=f2d504006ec97c7d84e8059c48f5a37e005ece5f;hpb=9ef77734bac36f2b16380ef3e131d3164fe241ce diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index 476927af..989d6758 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -10,45 +10,22 @@ class ObjectExporter: return lods - def export_object_resources(self, ctx, obj, resources, material_atlases): - if material_atlases is None: - material_atlases = {} - + def export_object_resources(self, ctx, obj, resources): lods = self.collect_object_lods(obj) from .export_mesh import MeshExporter - from .export_material import MaterialAtlasExporter, MaterialExporter + from .export_material import MaterialExporter from .mesh import create_mesh_from_object - from .material import Material, create_material_atlas + from .material import Material mesh_export = MeshExporter() material_export = MaterialExporter() - material_atlas_export = MaterialAtlasExporter() ctx.set_slices(len(lods)) for l in lods: lod_index = l.lod_index if l.lod_for_parent else 0 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 any(atlas_flags): - mmk = lambda m: m.shader if m.render_mode=='CUSTOM' else "" - material_atlas_key = mmk(l.data.materials[0]) - key_mismatch = any(mmk(m)!=material_atlas_key for m in l.data.materials) - if not all(atlas_flags) or key_mismatch: - raise Exception("Invalid configuration on object {}: Mixed material atlas state") - - if material_atlas_key in material_atlases: - material_atlas = material_atlases[material_atlas_key] - else: - 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) - if tech_name not in resources: - material_atlas_export.export_technique_resources(material_atlas, resources) - resources[tech_name] = material_atlas_export.export_technique(material_atlas, resources) - elif l.material_slots and l.material_slots[0].material: + if 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': @@ -63,7 +40,7 @@ class ObjectExporter: mesh_name = l.data.name+".mesh" if mesh_name not in resources: subtask = task.task(l.data, 1.0) - mesh = create_mesh_from_object(subtask, l, material_atlas) + mesh = create_mesh_from_object(subtask, l) mesh_res = mesh_export.export_mesh(subtask, mesh) resources[mesh_name] = mesh_res @@ -98,8 +75,6 @@ class ObjectExporter: if material: if material.render_mode=='EXTERNAL': tech_name = material.technique - elif material.material_atlas: - tech_name = "material_atlas_{}.tech".format(os.path.splitext(material.technique)[0]) else: tech_name = material.name+".tech" else: