2 "name": "Msp GL datafiles",
3 "author": "Mikko Rasa",
4 "location": "File > Export",
5 "description": "Export Msp GL data",
6 "category": "Import-Export" }
10 for sub in "export_mesh", "mesh", "outfile", "util":
12 imp.reload(locals()[sub])
15 from bpy_extras.io_utils import ExportHelper
17 class ExportMspGLMeshBase(ExportHelper):
18 use_strips = bpy.props.BoolProperty(name="Use strips", description="Combine faces into triangle strips", default=True)
19 use_degen_tris = bpy.props.BoolProperty(name="Use degen tris", description="Concatenate triangle strips with degenerate triangles", default=False)
20 max_strip_len = bpy.props.IntProperty(name="Max strip length", description="Maximum length for a triangle strip", default=1024, min=4, max=16384)
21 optimize_cache = bpy.props.BoolProperty(name="Optimize cache", description="Optimize element order for vertex cache", default=True)
22 cache_size = bpy.props.IntProperty(name="Cache size", description="Simulated vertex cache size used in optimization", default=64, min=8, max=1024)
23 export_lines = bpy.props.BoolProperty(name="Export lines", description="Export edges without faces as lines", default=False)
24 export_uv = bpy.props.EnumProperty(name="Export UV", description="Export UV coordinates", default="UNIT0",
25 items=(("NONE", "None", "No UV coordinates are exported"),
26 ("UNIT0", "Unit 0", "UV coordinates for unit 0 are exported"),
27 ("ALL", "All", "All UV coordinates are exported")))
28 tbn_vecs = bpy.props.BoolProperty(name="TBN vectors", description="Compute tangent and binormal vectors for vertices", default=False)
29 tbn_uvtex = bpy.props.StringProperty(name="TBN UV layer", description="UV layer to use as basis for TBN vectors", default="")
30 compound = bpy.props.BoolProperty(name="Compound", description="Combine all selected objects into one for exporting", default=False)
31 smoothing = bpy.props.EnumProperty(name="Smoothing", description="Smoothing method to use", default="MSPGL",
32 items=(("NONE", "None", "No smoothing"),
33 ("BLENDER", "Blender", "Use Blender's vertex normals"),
34 ("MSPGL", "MspGL", "Compute vertex normals internally")))
36 def execute(self, context):
37 from .export_mesh import MeshExporter
38 exporter = MeshExporter()
39 self.prepare_exporter(exporter)
40 exporter.export(context, self.filepath)
43 def prepare_exporter(self, exporter):
44 for k, v in self.as_keywords().items():
45 setattr(exporter, k, v)
47 def draw(self, context):
48 col = self.layout.column()
49 col.prop(self, "export_lines")
50 col.prop(self, "compound")
51 col.prop(self, "smoothing")
52 self.layout.separator()
53 col = self.layout.column()
54 col.label("Triangle strips")
55 col.prop(self, "use_strips")
56 col.prop(self, "use_degen_tris")
57 col.prop(self, "max_strip_len")
58 self.layout.separator()
59 col = self.layout.column()
60 col.label("Vertex cache")
61 col.prop(self, "optimize_cache")
62 col.prop(self, "cache_size")
63 self.layout.separator()
64 col = self.layout.column()
65 col.label("TBN vectors")
66 col.prop(self, "tbn_vecs")
67 col.prop(self, "tbn_uvtex")
69 class ExportMspGLMesh(bpy.types.Operator, ExportMspGLMeshBase):
70 bl_idname = "export_mesh.mspgl_mesh"
71 bl_label = "Export Msp GL mesh"
73 filename_ext = ".mesh"
75 class ExportMspGLObject(bpy.types.Operator, ExportMspGLMeshBase):
76 bl_idname = "export_mesh.mspgl_object"
77 bl_label = "Export Msp GL object"
79 filename_ext = ".object"
81 textures = bpy.props.EnumProperty(name="Textures", description="Export textures", default="REF",
82 items=(("NONE", "None", "Ignore textures"),
83 ("REF", "Referenced", "Reference external data"),
84 ("INLINE", "Inline", "Embed textures in the object")))
85 material_tex = bpy.props.BoolProperty(name="Material texture", description="Generate a texture based on material colors", default=False)
87 def prepare_exporter(self, exporter):
88 super().prepare_exporter(exporter)
89 exporter.object = True
91 def draw(self, context):
93 self.layout.separator()
94 col = self.layout.column()
95 col.label("Texturing")
96 col.prop(self, "textures")
97 col.prop(self, "material_tex")
99 def menu_func_export(self, context):
100 self.layout.operator(ExportMspGLMesh.bl_idname, text="Msp GL mesh")
101 self.layout.operator(ExportMspGLObject.bl_idname, text="Msp GL object")
104 bpy.utils.register_module(__name__)
106 bpy.types.INFO_MT_file_export.append(menu_func_export)
109 bpy.utils.unregister_module(__name__)
111 bpy.types.INFO_MT_file_export.remove(menu_func_export)
113 if __name__=="__main__":