]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_armature.py
Support for exporting armatures and vertex groups
[libs/gl.git] / blender / io_mspgl / export_armature.py
diff --git a/blender/io_mspgl/export_armature.py b/blender/io_mspgl/export_armature.py
new file mode 100644 (file)
index 0000000..1d70b59
--- /dev/null
@@ -0,0 +1,21 @@
+from .outfile import OutFile
+
+class ArmatureExporter:
+       def export(self, context, fn):
+               obj = context.active_object
+               if obj.type!="ARMATURE":
+                       raise Exception("Can only export Armature data")
+
+               from .armature import Armature
+
+               armature = Armature(obj.data)
+               armature.sort_links()
+
+               out_file = OutFile(fn)
+               for l in armature.links:
+                       out_file.begin("link", '"{}"'.format(l.name))
+                       out_file.write("index", l.index)
+                       if l.parent:
+                               out_file.write("parent", '"{}"'.format(l.parent.name))
+                       out_file.write("base", *tuple(l.base))
+                       out_file.end()