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", "datafile", "export_armature", "export_camera", "export_material", "export_mesh", "export_object", "export_scene", "export_texture", "material", "mesh", "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_to_file(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 single_file = bpy.props.BoolProperty(name="Single file", description="Write all data into a single file", default=True)
62 shared_resources = bpy.props.BoolProperty(name="Shared resources", description="Use global names for resource files to enable sharing", default=True)
64 export_lods = bpy.props.BoolProperty(name="Export LoDs", description="Export all levels of detail", default=True)
65 use_textures = bpy.props.BoolProperty(name="Use textures", description="Use textures in the exported object", default=True)
67 def create_exporter(self):
68 from .export_object import ObjectExporter
69 return ObjectExporter()
71 def draw(self, context):
74 self.general_col.prop(self, "export_lods")
75 self.general_col.prop(self, "use_textures")
77 col = self.layout.column()
79 col.prop(self, "single_file")
80 if not self.single_file:
81 col.prop(self, "shared_resources")
83 class ExportMspGLArmature(bpy.types.Operator, ExportMspGLBase):
84 bl_idname = "export.mspgl_armature"
85 bl_label = "Export Msp GL armature"
87 filename_ext = ".arma"
89 def create_exporter(self):
90 from .export_armature import ArmatureExporter
91 return ArmatureExporter()
93 class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase):
94 bl_idname = "export_scene.mspgl_scene"
95 bl_label = "Export Msp GL scene"
97 filename_ext = ".scene"
99 resource_collection = bpy.props.BoolProperty(name="Resource collection", description="Put resources to a single collection file", default=True)
101 def create_exporter(self):
102 from .export_scene import SceneExporter
103 return SceneExporter()
105 def draw(self, context):
106 col = self.layout.column()
107 col.prop(self, "resource_collection")
109 class ExportMspGLCamera(bpy.types.Operator, ExportMspGLBase):
110 bl_idname = "export.mspgl_camera"
111 bl_label = "Export Msp GL camera"
113 filename_ext = ".camera"
115 def create_exporter(self):
116 from .export_camera import CameraExporter
117 return CameraExporter()
119 def menu_func_export(self, context):
120 self.layout.operator(ExportMspGLMesh.bl_idname, text="Msp GL mesh")
121 self.layout.operator(ExportMspGLObject.bl_idname, text="Msp GL object")
122 self.layout.operator(ExportMspGLArmature.bl_idname, text="Msp GL armature")
123 self.layout.operator(ExportMspGLScene.bl_idname, text="Msp GL scene")
124 self.layout.operator(ExportMspGLCamera.bl_idname, text="Msp GL camera")
126 from .properties import MspGLMeshProperties, MspGLObjectProperties
129 bpy.utils.register_module(__name__)
131 bpy.types.INFO_MT_file_export.append(menu_func_export)
133 from .properties import register_properties
134 register_properties()
137 bpy.utils.unregister_module(__name__)
139 bpy.types.INFO_MT_file_export.remove(menu_func_export)
141 if __name__=="__main__":