]> git.tdb.fi Git - libs/gl.git/commitdiff
Add an option to use shared meshes when exporting
authorMikko Rasa <tdb@tdb.fi>
Sat, 28 Nov 2015 15:27:02 +0000 (17:27 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 28 Nov 2015 15:27:02 +0000 (17:27 +0200)
blender/io_mspgl/__init__.py
blender/io_mspgl/export_object.py

index c13345fafa224bdc69b1b7987ee59778f395d8ae..0731c32f92c938881f22248fa19a350534eed6f9 100644 (file)
@@ -108,6 +108,7 @@ class ExportMspGLObject(bpy.types.Operator, ExportMspGLMeshBase):
        srgb_colors = bpy.props.BoolProperty(name="sRGB colors", description="Export material colors as sRGB instead of linear", default=True)
 
        separate_mesh = bpy.props.BoolProperty(name="Separate mesh", description="Write mesh data into a separate file", default=False)
+       shared_mesh = bpy.props.BoolProperty(name="Shared mesh", description="Use mesh name for mesh file to enable sharing", default=True)
        separate_tech = bpy.props.BoolProperty(name="Separate technique", description="Write technique data into a separate file", default=False)
        shared_tech = bpy.props.BoolProperty(name="Shared technique", description="Use material name for technique file to enable sharing", default=True)
 
@@ -134,6 +135,8 @@ class ExportMspGLObject(bpy.types.Operator, ExportMspGLMeshBase):
                col = self.layout.column()
                col.label("Files")
                col.prop(self, "separate_mesh")
+               if self.separate_mesh:
+                       col.prop(self, "shared_mesh")
                col.prop(self, "separate_tech")
                if self.separate_tech:
                        col.prop(self, "shared_tech")
index b911ed362bb242bc84f7f040a7ac25b90ac3e99a..1fccfb79d1cf26116e506d561d25040bd1da36a4 100644 (file)
@@ -28,6 +28,7 @@ class ObjectExporter:
                self.srgb_colors = True
                self.textures = "REF"
                self.separate_mesh = False
+               self.shared_mesh = True
                self.separate_tech = False
                self.external_tech = True
                self.shared_tech = True
@@ -70,7 +71,7 @@ class ObjectExporter:
 
                        same_mesh = (l.data.name==prev_mesh)
                        if i==0 or not same_mesh:
-                               mesh = self.export_object_mesh(context, out_file, i, objs, progress)
+                               mesh = self.export_object_mesh(context, out_file, l, objs, progress)
                                prev_mesh = l.data.name
 
                        same_tech = True
@@ -88,15 +89,21 @@ class ObjectExporter:
                        if i>0:
                                out_file.end()
 
-       def export_object_mesh(self, context, out_file, lod_index, objs, progress):
+       def export_object_mesh(self, context, out_file, lod, objs, progress):
                from .export_mesh import MeshExporter
                mesh_export = MeshExporter()
                for k, v in self.__dict__.items():
                        setattr(mesh_export, k, v)
 
+               lod_index = 0
+               if lod.lod_for_parent:
+                       lod_index = lod.lod_index
+
                if self.separate_mesh:
                        from .outfile import open_output
                        path, name = external_name(out_file, ".mesh", lod_index)
+                       if self.shared_mesh:
+                               name = lod.data.name+".mesh"
                        mesh_out = open_output(os.path.join(path, name))
                        mesh = mesh_export.export(context, mesh_out, objs, progress)
                        out_file.write("mesh", '"{}"'.format(name))