object_prototypes = {}
unique_objects = []
+ export_names = {}
for o in objs:
if o.name in object_prototypes:
continue
clones.append(u)
+ prefix = o.name
+ for c in clones:
+ for i in range(min(len(c.name), len(prefix))):
+ if c.name[i]!=prefix[i]:
+ prefix = prefix[:i]
+ break
+
+ if prefix:
+ export_names[o.name+".object"] = prefix.strip(" .")+".object"
+
unique_objects.append(o)
for c in clones:
object_prototypes[c.name] = o
resources = {}
self.export_scene_resources(context, unique_objects, resources, progress)
+ for n, r in resources.items():
+ if r.name in export_names:
+ r.name = export_names[r.name]
scene_res = self.export_scene(context, objs, progress, prototypes=object_prototypes, resources=resources)
refs = scene_res.collect_references()
keywords = { ".mat": "material",
".mesh": "mesh",
".object": "object",
- ".tech": "technique" }
+ ".tech": "technique",
+ ".tex2d": "texture2d" }
with open(os.path.join(path, base+"_resources.mdc"), "w") as res_out:
for r in refs:
st = Statement(keywords[os.path.splitext(r.name)[1]], r.name)
def export_scene_resources(self, context, objs, resources, progress):
from .export_object import ObjectExporter
object_export = ObjectExporter()
- object_export.separate_mesh = True
- object_export.separate_tech = True
+ object_export.single_file = False
+
+ material_maps = {}
for i, o in enumerate(objs):
progress.push_task_slice(o.name, i, len(objs))
- object_export.export_object_resources(context, o, resources, progress)
+ object_export.export_object_resources(context, o, resources, progress, material_maps=material_maps)
obj_name = o.name+".object"
resources[obj_name] = object_export.export_object(context, o, progress, resources=resources)
progress.pop_task()