X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_object.py;h=7b9ee6a44cfb2c8eb888c237b7e1579e358c1fff;hb=1bad86b461abd4fe2a1cb1c6c5685adf5db13935;hp=12b15b63c26586abe203629992782d594b266a64;hpb=912ae952489699769be43f90d4478263461964a4;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index 12b15b63..7b9ee6a4 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -1,3 +1,5 @@ +import os + def linear_to_srgb(l): if l<0.0031308: return 12.92*l @@ -10,8 +12,14 @@ class ObjectExporter: self.material_tex = False 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) @@ -20,11 +28,35 @@ 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") + 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: @@ -102,4 +134,3 @@ class ObjectExporter: out_file.end() out_file.end() - out_file.end()