return strips, loose
- def export(self, context, out_file, objs=None):
+ def export(self, context, out_file, objs=None, progress=None):
if self.compound:
if objs is None:
objs = context.selected_objects
from .mesh import Mesh
from .util import Progress
- progress = Progress(context)
+ if not progress:
+ progress = Progress(context)
progress.set_task("Preparing", 0.0, 0.0)
mesh = None
else:
mesh.splice(Mesh(bmesh))
- progress.set_task("Smoothing", 0.05, 0.35)
+ if progress:
+ progress.set_task("Smoothing", 0.05, 0.35)
if self.smoothing=="NONE":
mesh.flatten_faces()
mesh.split_smooth(progress)
texunits.insert(0, unit)
for i, u in texunits:
- progress.set_task("Splitting UVs", 0.35+0.3*i/len(texunits), 0.35+0.3*(i+1)/len(texunits))
+ if progress:
+ progress.set_task("Splitting UVs", 0.35+0.3*i/len(texunits), 0.35+0.3*(i+1)/len(texunits))
mesh.split_uv(i, progress)
if self.tbn_vecs and u.name==self.tbn_uvtex:
mesh.compute_uv()
strips = []
loose = mesh.faces
if self.use_strips:
- progress.set_task("Creating strips", 0.65, 0.95)
+ if progress:
+ progress.set_task("Creating strips", 0.65, 0.95)
strips, loose = self.stripify(mesh, progress)
- progress.set_task("Writing file", 0.95, 1.0)
+ if progress:
+ progress.set_task("Writing file", 0.95, 1.0)
from .outfile import open_output
out_file = open_output(out_file)
out_file.write("indices", l.vertices[0].index, l.vertices[1].index)
out_file.end()
- progress.set_task("Done", 1.0, 1.0)
+ if progress:
+ progress.set_task("Done", 1.0, 1.0)
for m in bmeshes:
bpy.data.meshes.remove(m)
self.external_tech = True
self.shared_tech = True
- def export(self, context, out_file, objs=None):
+ def export(self, context, out_file, objs=None, progress=None):
if objs is None:
obj = context.active_object
else:
path, base = os.path.split(out_file.filename)
base, ext = os.path.splitext(base)
mesh_out = open_output(os.path.join(path, base+".mesh"))
- mesh = mesh_export.export(context, mesh_out, objs)
+ mesh = mesh_export.export(context, mesh_out, objs, progress)
out_file.write("mesh", '"{}.mesh"'.format(base))
else:
out_file.begin("mesh")
- mesh = mesh_export.export(context, out_file, objs)
+ mesh = mesh_export.export(context, out_file, objs, progress)
out_file.end()
if self.external_tech and obj.technique:
object_export.compound = True
object_export.external_tech = self.external_tech
+ from .util import Progress
+ progress = Progress(context)
if self.resource_collection:
res_out = open_output(os.path.join(path, base+"_resources.mdc"))
# TODO Export techniques as separate items in the collection
- for o in objs:
+ for i, o in enumerate(objs):
res_out.begin("object", '"{}.object"'.format(o.name))
- object_export.export(context, res_out, [o])
+ progress.push_task(o.name, i/len(objs), (i+1)/len(objs))
+ object_export.export(context, res_out, [o], progress)
+ progress.pop_task()
res_out.end()
else:
object_export.separate_tech = True
os.makedirs(res_dir)
for o in objs:
obj_out = open_output(os.path.join(res_dir, o.name+".object"))
- object_export.export(context, obj_out, [o])
+ progress.push_task(o.name, i/len(objs), (i+1)/len(objs))
+ object_export.export(context, obj_out, [o], progress)
+ progress.pop_task()
for o in objs:
out_file.begin("object", '"{}.object"'.format(o.name))
self.start = 0.0
self.delta = 1.0
self.last = 0.0
+ self.stack = []
self.window_manager = context.window_manager
self.window_manager.progress_begin(0.0, 1.0)
+ def push_task(self, task, low, high):
+ self.stack.append((task, low, high-low))
+ self.set_task("init", 0.0, 0.0)
+
+ def pop_task(self):
+ self.set_task("finish", 1.0, 1.0)
+ self.stack.pop()
+
def set_task(self, task, low, high):
+ if self.stack:
+ task = self.stack[-1][0]+": "+task
+ low = self.stack[-1][1]+self.stack[-1][2]*low
+ high = self.stack[-1][1]+self.stack[-1][2]*high
+
self.task = task
self.start = low
self.delta = high-low
+
self.set_progress(0)
def set_progress(self, value):