--- /dev/null
+#!BPY
+# $Id$
+
+"""
+Name: 'MSP GL Mesh (.mesh)...'
+Blender: 244
+Group: 'Export'
+"""
+
+import sys
+import Blender
+
+class Exporter:
+ def __init__(self, fn):
+ self.filename=fn
+ if fn==None:
+ self.out_file=sys.stdout
+ else:
+ self.out_file=file(fn, "w")
+
+ def export(self):
+ scene=Blender.Scene.GetCurrent()
+
+ obj=scene.getActiveObject()
+ if obj.getType()!="Mesh":
+ raise Exception, "Can only export Mesh data"
+
+ mesh=obj.getData(mesh=True)
+
+ self.out_file.write("vertices NORMAL3,VERTEX3\n{\n")
+ for v in mesh.verts:
+ self.out_file.write("\tnormal3 %g %g %g;\n"%tuple(v.no))
+ self.out_file.write("\tvertex3 %g %g %g;\n"%tuple(v.co))
+ self.out_file.write("};\n")
+ self.out_file.write("batch TRIANGLES\n{\n")
+ for f in mesh.faces:
+ for i in range(2, len(f.verts)):
+ self.out_file.write("\tindices %u %u %u;\n"%(f.verts[0].index, f.verts[i-1].index, f.verts[i].index))
+ self.out_file.write("};\n")
+
+class FrontEnd:
+ def run(self):
+ #self.export(None)
+ Blender.Window.FileSelector(self.export, "Export MSP GL mesh", Blender.sys.makename(ext='.mesh'))
+
+ def export(self, fn):
+ exp=Exporter(fn)
+ exp.export()
+
+if __name__=="__main__":
+ fe=FrontEnd()
+ fe.run()