]> git.tdb.fi Git - libs/gl.git/blob - blender/io_mesh_mspgl/__init__.py
Adapt to changes in bpy API
[libs/gl.git] / blender / io_mesh_mspgl / __init__.py
1 bl_info = {
2         "name": "Msp GL format",
3         "author": "Mikko Rasa",
4         "location": "File > Export",
5         "description": "Export Msp GL meshes and objects",
6         "category": "Import-Export" }
7
8 if "bpy" in locals():
9         import imp
10         for sub in "export_mspgl", "mesh", "util":
11                 if sub in locals():
12                         imp.reload(locals()[sub])
13
14 import bpy
15 from io_utils import ExportHelper
16
17 class ExportMspGL(bpy.types.Operator, ExportHelper):
18         bl_idname = "export_mesh.mspgl"
19         bl_label = "Export Msp GL data"
20
21         filename_ext = ".mesh"
22
23         use_strips = bpy.props.BoolProperty(name="Use strips", description="Combine faces into triangle strips", default=True)
24         use_degen_tris = bpy.props.BoolProperty(name="Use degen tris", description="Concatenate triangle strips with degenerate triangles", default=False)
25         max_strip_len = bpy.props.IntProperty(name="Max strip length", description="Maximum length for a triangle strip", default=1024, min=4, max=16384)
26         optimize_cache = bpy.props.BoolProperty(name="Optimize cache", description="Optimize element order for vertex cache", default=True)
27         cache_size = bpy.props.IntProperty(name="Cache size", description="Simulated vertex cache size used in optimization", default=64, min=8, max=1024)
28         export_lines = bpy.props.BoolProperty(name="Export lines", description="Export edges without faces as lines", default=False)
29         export_uv = bpy.props.EnumProperty(name="Export UV", description="Export UV coordinates", default="UNIT0",
30                 items=(("NONE", "None", "No UV coordinates are exported"),
31                         ("UNIT0", "Unit 0", "UV coordinates for unit 0 are exported"),
32                         ("ALL", "All", "All UV coordinates are exported")))
33         tbn_vecs = bpy.props.BoolProperty(name="TBN vectors", description="Compute tangent and binormal vectors for vertices", default=False)
34         tbn_uvtex = bpy.props.StringProperty(name="TBN UV layer", description="UV layer to use as basis for TBN vectors", default="")
35         compound = bpy.props.BoolProperty(name="Compound", description="Combine all selected objects into one for exporting", default=False)
36         object = bpy.props.BoolProperty(name="Object", description="Export an object instead of a mesh", default=False)
37         material_tex = bpy.props.BoolProperty(name="Material texture", description="Generate a texture based on material colors", default=False)
38         smoothing = bpy.props.EnumProperty(name="Smoothing", description="Smoothing method to use", default="MSPGL",
39                 items=(("NONE", "None", "No smoothing"),
40                         ("BLENDER", "Blender", "Use Blender's vertex normals"),
41                         ("MSPGL", "MspGL", "Compute vertex normals internally")))
42
43         def execute(self, context):
44                 from . import export_mspgl
45                 exporter = export_mspgl.Exporter()
46                 for k, v in self.as_keywords().items():
47                         setattr(exporter, k, v)
48                 exporter.export(context, self.filepath)
49                 return {"FINISHED"}
50
51 def menu_func_export(self, context):
52         self.layout.operator(ExportMspGL.bl_idname, text="Msp GL")
53
54 def register():
55         bpy.utils.register_module(__name__)
56
57         bpy.types.INFO_MT_file_export.append(menu_func_export)
58
59 def unregister():
60         bpy.utils.unregister_module(__name__)
61
62         bpy.types.INFO_MT_file_export.remove(menu_func_export)
63
64 if __name__=="__main__":
65         register()