]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_object.py
More options for exporting techniques
[libs/gl.git] / blender / io_mspgl / export_object.py
index 8065c09ad4a2bac0219eb7ed2254b4c3dfcb6ab8..7b9ee6a44cfb2c8eb888c237b7e1579e358c1fff 100644 (file)
@@ -13,8 +13,13 @@ class ObjectExporter:
                self.srgb_colors = True
                self.textures = "REF"
                self.separate_mesh = False
+               self.separate_tech = False
+               self.external_tech = True
+               self.shared_tech = True
 
        def export(self, context, out_file):
+               obj = context.active_object
+
                from .outfile import open_output
                out_file = open_output(out_file)
 
@@ -34,7 +39,24 @@ class ObjectExporter:
                        mesh = mesh_export.export(context, out_file)
                        out_file.end()
 
-               out_file.begin("technique")
+               if self.external_tech and obj.technique:
+                       out_file.write("technique", '"{}"'.format(obj.technique))
+               elif self.separate_tech:
+                       path, base = os.path.split(out_file.filename)
+                       if self.shared_tech and mesh.materials:
+                               tech_name = mesh.materials[0].name+".tech"
+                       else:
+                               base, ext = os.path.splitext(base)
+                               tech_name = base+".tech"
+                       tech_out = open_output(os.path.join(path, tech_name))
+                       self.export_technique(mesh, tech_out)
+                       out_file.write("technique", '"{}"'.format(tech_name))
+               else:
+                       out_file.begin("technique")
+                       self.export_technique(mesh, out_file)
+                       out_file.end()
+
+       def export_technique(self, mesh, out_file):
                out_file.begin("pass", '""')
                if mesh.materials:
                        if self.srgb_colors:
@@ -112,4 +134,3 @@ class ObjectExporter:
                                        out_file.end()
 
                out_file.end()
-               out_file.end()