X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=blender%2Fio_mspgl%2Fexport_object.py;h=d89afd05df667fb7c26d648a167bde38cc7ff8f8;hb=47abe7c9e1633ca65f910a4db340724117a6f6e5;hp=8065c09ad4a2bac0219eb7ed2254b4c3dfcb6ab8;hpb=44fc9b88ead11e7325bd193e4c853f8b10e9b175;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_object.py b/blender/io_mspgl/export_object.py index 8065c09a..d89afd05 100644 --- a/blender/io_mspgl/export_object.py +++ b/blender/io_mspgl/export_object.py @@ -13,8 +13,16 @@ 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, objs=None): + if objs is None: + obj = context.active_object + else: + obj = objs[0] - def export(self, context, out_file): from .outfile import open_output out_file = open_output(out_file) @@ -27,14 +35,31 @@ class ObjectExporter: 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\"") + mesh = mesh_export.export(context, mesh_out, objs) + out_file.write("mesh", '"{}.mesh"'.format(base)) else: out_file.begin("mesh") - mesh = mesh_export.export(context, out_file) + mesh = mesh_export.export(context, out_file, objs) + out_file.end() + + 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() - out_file.begin("technique") + def export_technique(self, mesh, out_file): out_file.begin("pass", '""') if mesh.materials: if self.srgb_colors: @@ -112,4 +137,3 @@ class ObjectExporter: out_file.end() out_file.end() - out_file.end()