max_strip_len = bpy.props.IntProperty(name="Max strip length", description="Maximum length for a triangle strip", default=1024, min=4, max=16384)
optimize_cache = bpy.props.BoolProperty(name="Optimize cache", description="Optimize element order for vertex cache", default=True)
cache_size = bpy.props.IntProperty(name="Cache size", description="Simulated vertex cache size used in optimization", default=64, min=8, max=1024)
- compound = bpy.props.BoolProperty(name="Compound", description="Combine all selected objects into one for exporting", default=False)
def draw(self, context):
- col = self.layout.column()
- col.prop(self, "compound")
- self.general_col = col
-
- self.layout.separator()
+ self.general_col = self.layout.column()
col = self.layout.column()
col.label("Triangle strips")
col.prop(self, "external_tech")
col.prop(self, "export_lods")
col.prop(self, "textures")
+ col.separator()
self.layout.separator();
self.max_strip_len = 1024
self.optimize_cache = True
self.cache_size = 64
- self.compound = False
self.material_tex = False
def stripify(self, mesh, progress=None):
return strips, loose
- def export(self, context, out_file, objs=None, progress=None):
- if objs:
- objs = [(o, mathutils.Matrix()) for o in objs]
-
- if self.compound:
- if objs is None:
- objs = [(o, mathutils.Matrix()) for o in context.selected_objects]
- check = objs
- while check:
- children = []
- for o, m in check:
- for c in o.children:
- if c.compound:
- children.append((c, m*c.matrix_local))
- objs += children
- check = children
- elif objs is None:
- objs = [(context.active_object, mathutils.Matrix())]
+ def export(self, context, out_file, obj=None, progress=None):
+ if obj is None:
+ obj = context.active_object
+
+ objs = [(obj, mathutils.Matrix())]
+ check = objs
+ while check:
+ children = []
+ for o, m in check:
+ for c in o.children:
+ if c.compound:
+ children.append((c, m*c.matrix_local))
+ objs += children
+ check = children
if not objs:
raise Exception("Nothing to export")
self.shared_tech = True
self.export_lods = True
- def export(self, context, out_file, objs=None, progress=None):
- if objs is None:
+ def export(self, context, out_file, obj=None, progress=None):
+ if obj is None:
obj = context.active_object
- else:
- obj = objs[0]
lods = [obj]
for c in obj.children:
for i, l in enumerate(lods):
if i>0:
out_file.begin("level_of_detail", i)
- objs = [l]
if i==0 or l.data.name!=prev_mesh:
- mesh = self.export_object_mesh(context, out_file, l, objs, progress)
+ mesh = self.export_object_mesh(context, out_file, l, progress)
prev_mesh = l.data.name
same_tech = True
if i>0:
out_file.end()
- def export_object_mesh(self, context, out_file, lod, objs, progress):
+ def export_object_mesh(self, context, out_file, obj, progress):
from .export_mesh import MeshExporter
mesh_export = MeshExporter()
for k, v in self.__dict__.items():
setattr(mesh_export, k, v)
lod_index = 0
- if lod.lod_for_parent:
- lod_index = lod.lod_index
+ if obj.lod_for_parent:
+ lod_index = obj.lod_index
if self.separate_mesh:
from .outfile import open_output
path, name = external_name(out_file, ".mesh", lod_index)
if self.shared_mesh:
- name = lod.data.name+".mesh"
+ name = obj.data.name+".mesh"
mesh_out = open_output(os.path.join(path, name))
- mesh = mesh_export.export(context, mesh_out, objs, progress)
+ mesh = mesh_export.export(context, mesh_out, obj, progress)
out_file.write("mesh", '"{}"'.format(name))
else:
out_file.begin("mesh")
- mesh = mesh_export.export(context, out_file, objs, progress)
+ mesh = mesh_export.export(context, out_file, obj, progress)
out_file.end()
return mesh
from .export_object import ObjectExporter
object_export = ObjectExporter()
- object_export.compound = True
object_export.external_tech = self.external_tech
object_prototypes = {}
for i, o in enumerate(unique_objects):
res_out.begin("object", '"{}.object"'.format(o.name))
progress.push_task(o.name, i/len(objs), (i+1)/len(objs))
- object_export.export(context, res_out, [o], progress)
+ object_export.export(context, res_out, o, progress)
progress.pop_task()
res_out.end()
else:
for i, o in enumerate(unique_objects):
obj_out = open_output(os.path.join(res_dir, o.name+".object"))
progress.push_task(o.name, i/len(objs), (i+1)/len(objs))
- object_export.export(context, obj_out, [o], progress)
+ object_export.export(context, obj_out, o, progress)
progress.pop_task()
for o in objs: