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 "armature", "export_armature", "export_mesh", "export_object", "export_scene", "mesh", "outfile", "properties", "util":
12 imp.reload(locals()[sub])
15 from bpy_extras.io_utils import ExportHelper
17 class ExportMspGLBase(ExportHelper):
18 show_progress = bpy.props.BoolProperty(name="Show progress", description="Display progress indicator while exporting", default=True)
20 def execute(self, context):
21 exporter = self.create_exporter()
22 self.prepare_exporter(exporter)
23 exporter.export(context, self.filepath)
26 def create_exporter(self):
27 raise Exception("create_exporter must be overridden")
29 def prepare_exporter(self, exporter):
30 for k, v in self.as_keywords().items():
31 setattr(exporter, k, v)
33 class ExportMspGLMeshBase(ExportMspGLBase):
34 use_strips = bpy.props.BoolProperty(name="Use strips", description="Combine faces into triangle strips", default=True)
35 use_degen_tris = bpy.props.BoolProperty(name="Use degen tris", description="Concatenate triangle strips with degenerate triangles", default=False)
37 def draw(self, context):
38 self.general_col = self.layout.column()
40 col = self.layout.column()
41 col.label("Triangle strips")
42 col.prop(self, "use_strips")
43 col.prop(self, "use_degen_tris")
45 class ExportMspGLMesh(bpy.types.Operator, ExportMspGLMeshBase):
46 bl_idname = "export_mesh.mspgl_mesh"
47 bl_label = "Export Msp GL mesh"
49 filename_ext = ".mesh"
51 def create_exporter(self):
52 from .export_mesh import MeshExporter
55 class ExportMspGLObject(bpy.types.Operator, ExportMspGLMeshBase):
56 bl_idname = "export_mesh.mspgl_object"
57 bl_label = "Export Msp GL object"
59 filename_ext = ".object"
61 textures = bpy.props.EnumProperty(name="Textures", description="Export textures", default="REF",
62 items=(("NONE", "None", "Ignore textures"),
63 ("REF", "Referenced", "Reference external data"),
64 ("INLINE", "Inline", "Embed textures in the object")))
66 separate_mesh = bpy.props.BoolProperty(name="Separate mesh", description="Write mesh data into a separate file", default=False)
67 shared_mesh = bpy.props.BoolProperty(name="Shared mesh", description="Use mesh name for mesh file to enable sharing", default=True)
68 separate_tech = bpy.props.BoolProperty(name="Separate technique", description="Write technique data into a separate file", default=False)
69 shared_tech = bpy.props.BoolProperty(name="Shared technique", description="Use material name for technique file to enable sharing", default=True)
71 export_lods = bpy.props.BoolProperty(name="Export LoDs", description="Export all levels of detail", default=True)
73 def create_exporter(self):
74 from .export_object import ObjectExporter
75 return ObjectExporter()
77 def draw(self, context):
80 col = self.general_col
81 col.prop(self, "export_lods")
82 col.prop(self, "textures")
85 self.layout.separator()
87 col = self.layout.column()
89 col.prop(self, "separate_mesh")
90 if self.separate_mesh:
91 col.prop(self, "shared_mesh")
92 col.prop(self, "separate_tech")
93 if self.separate_tech:
94 col.prop(self, "shared_tech")
96 class ExportMspGLArmature(bpy.types.Operator, ExportMspGLBase):
97 bl_idname = "export.mspgl_armature"
98 bl_label = "Export Msp GL armature"
100 filename_ext = ".arma"
102 def create_exporter(self):
103 from .export_armature import ArmatureExporter
104 return ArmatureExporter()
106 class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase):
107 bl_idname = "export_scene.mspgl_scene"
108 bl_label = "Export Msp GL scene"
110 filename_ext = ".scene"
112 resource_collection = bpy.props.BoolProperty(name="Resource collection", description="Put resources to a single collection file", default=True)
114 def create_exporter(self):
115 from .export_scene import SceneExporter
116 return SceneExporter()
118 def draw(self, context):
119 col = self.layout.column()
120 col.prop(self, "resource_collection")
122 def menu_func_export(self, context):
123 self.layout.operator(ExportMspGLMesh.bl_idname, text="Msp GL mesh")
124 self.layout.operator(ExportMspGLObject.bl_idname, text="Msp GL object")
125 self.layout.operator(ExportMspGLArmature.bl_idname, text="Msp GL armature")
126 self.layout.operator(ExportMspGLScene.bl_idname, text="Msp GL scene")
128 from .properties import MspGLMeshProperties, MspGLObjectProperties
131 bpy.utils.register_module(__name__)
133 bpy.types.INFO_MT_file_export.append(menu_func_export)
135 from .properties import register_properties
136 register_properties()
139 bpy.utils.unregister_module(__name__)
141 bpy.types.INFO_MT_file_export.remove(menu_func_export)
143 if __name__=="__main__":