]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_object.py
Add an option to export a separate mesh file when exporting an object
[libs/gl.git] / blender / io_mspgl / export_object.py
index 12b15b63c26586abe203629992782d594b266a64..8065c09ad4a2bac0219eb7ed2254b4c3dfcb6ab8 100644 (file)
@@ -1,3 +1,5 @@
+import os
+
 def linear_to_srgb(l):
        if l<0.0031308:
                return 12.92*l
@@ -10,6 +12,7 @@ class ObjectExporter:
                self.material_tex = False
                self.srgb_colors = True
                self.textures = "REF"
+               self.separate_mesh = False
 
        def export(self, context, out_file):
                from .outfile import open_output
@@ -20,9 +23,16 @@ class ObjectExporter:
                for k, v in self.__dict__.items():
                        setattr(mesh_export, k, v)
 
-               out_file.begin("mesh")
-               mesh = mesh_export.export(context, out_file)
-               out_file.end()
+               if self.separate_mesh:
+                       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)
+                       out_file.write("mesh", "\""+base+".mesh\"")
+               else:
+                       out_file.begin("mesh")
+                       mesh = mesh_export.export(context, out_file)
+                       out_file.end()
 
                out_file.begin("technique")
                out_file.begin("pass", '""')