]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_mesh.py
Add a Loader for Scene, and a matching Blender exporter
[libs/gl.git] / blender / io_mspgl / export_mesh.py
index cc8ee6ff9abbc1696fe2e13b16e752761ae7c58c..e429d7ae35ccd3c9daf4350e5decaf6e395084cb 100644 (file)
@@ -35,11 +35,11 @@ class VertexCache:
 class MeshExporter:
        def __init__(self):
                self.use_strips = True
-               self.use_degen_tris = True
+               self.use_degen_tris = False
                self.max_strip_len = 1024
-               self.optimize_cache = False
+               self.optimize_cache = True
                self.cache_size = 64
-               self.export_lines = True
+               self.export_lines = False
                self.export_uv = "UNIT0"
                self.tbn_vecs = False
                self.tbn_uvtex = ""
@@ -191,9 +191,10 @@ class MeshExporter:
 
                return strips, loose
 
-       def export(self, context, out_file):
+       def export(self, context, out_file, objs=None):
                if self.compound:
-                       objs = context.selected_objects
+                       if objs is None:
+                               objs = context.selected_objects
                        check = objs
                        while check:
                                children = []
@@ -203,7 +204,7 @@ class MeshExporter:
                                                        children.append(c)
                                objs += children
                                check = children
-               else:
+               elif objs is None:
                        objs = [context.active_object]
 
                if not objs:
@@ -312,7 +313,7 @@ class MeshExporter:
                fmt.append("VERTEX3")
                out_file.begin("vertices", *fmt)
                normal = None
-               uvs = [None]*(max(u[0] for u in texunits)+1)
+               uvs = {}
                tan = None
                bino = None
                group = None
@@ -321,7 +322,7 @@ class MeshExporter:
                                out_file.write("normal3", *v.normal)
                                normal = v.normal
                        for i, u in texunits:
-                               if v.uvs[i]!=uvs[i]:
+                               if v.uvs[i]!=uvs.get(i):
                                        if u.unit==0 or force_unit0:
                                                out_file.write("texcoord2", *v.uvs[i])
                                        else:
@@ -365,7 +366,7 @@ class MeshExporter:
                        out_file.end()
 
                if self.export_lines and mesh.lines:
-                       out_file.write("batch", "LINES")
+                       out_file.begin("batch", "LINES")
                        for l in mesh.lines:
                                out_file.write("indices", l.vertices[0].index, l.vertices[1].index)
                        out_file.end()