]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_scene.py
Some fixes for the scene exporter
[libs/gl.git] / blender / io_mspgl / export_scene.py
index 8f224fea8d418d183c70394e87b4176cfd748e07..fcd634fbf7330036c7880c4ef4ef2eca5f0fceb5 100644 (file)
@@ -1,7 +1,5 @@
 import math
 import os
-from .export_object import ObjectExporter
-from .outfile import OutFile
 
 class SceneExporter:
        def __init__(self):
@@ -10,7 +8,7 @@ class SceneExporter:
 
        def export(self, context, out_file):
                objs = context.selected_objects
-               objs = [o for o in objs if o.type=="MESH" and (not o.compound or o.parent not in objs)]
+               objs = [o for o in objs if o.type=="MESH" and (not o.compound or o.parent not in objs) and not o.lod_for_parent]
 
                from .outfile import open_output
                out_file = open_output(out_file)
@@ -18,17 +16,22 @@ class SceneExporter:
                path, base = os.path.split(out_file.filename)
                base, ext = os.path.splitext(base)
 
+               from .export_object import ObjectExporter
                object_export = ObjectExporter()
                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
@@ -37,7 +40,9 @@ class SceneExporter:
                                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))
@@ -54,4 +59,5 @@ class SceneExporter:
                                angle = q.angle
                                axis = q.axis
                        out_file.write("rotation", angle*180/math.pi, axis[0], axis[1], axis[2])
+                       out_file.write("scale", o.scale[0], o.scale[1], o.scale[2])
                        out_file.end();