Page 1 of 1

Exporting Armature Data

Posted: Tue May 25, 2004 12:06 am
by Matei
I've written a custom Python script to export mesh vertices, materials and faces in a simple format for a game. Right now, to handle animation, I'm just using Blender.NMesh.GetRawFromObject to export a deformed mesh based on the current frame, and I just export several frames and interpolate vertex positions/normals between them. However, there are two problems with this; first, it takes more space to store all these frames, and second, I have to export every frame of every object I want to use, and I'm planning to have very many similar objects (clothes, shields and weapons for characters). Instead, I'd like to export the frames of the armature used to animate the mesh, and then deform the mesh using this information in the game.

I've looked at the Python documentation, but it is very sparse, and I haven't found any sample scripts that do this either. So, do you have any suggestions about how I could:
- Get access to the armature as it is deformed in the current frame (something like Blender.NMesh.GetRawFromObject)
- Find out which mesh vertices are affected by each bone of the armature (and by how much, if two bones can affect the same vertex?); or, how to assign each vertex to a bone given the armature data
- Given the original mesh and the armature, deform the mesh using it in my game; I notice that each Bone object has a Quaternion associated with it, so I would probably need to do something like new position = (old position - old bone head) * quaternion + (new bone head). But are the quaternions relative to the bone's parent or are they absolute? Will I need to do anything else?

So far, the material I've seen about deformation using an armature seems to be pretty complicated, and I'm not even sure I should take this option over vertex position keyframes. But hopefully there's some straight-forward way to make it work.

Posted: Wed May 26, 2004 12:33 am
by der_ton
There are some scripts that do export meshes with skeletal animation. The godfather of them being Jiba's "blender2cal3d" script (I don't have a link, but it was distributed with Blender2.32). I, for example, wrote another script based on this one, for MD5 export ( - but it's not updated for Blender2.33 yet). Bob Holcomb is working on lots of stuff related to this, too:

If you use the search for this forum, or on, I'm sure you'll find lots of info on armature export.

Posted: Thu May 27, 2004 1:25 am
by Matei
I haven't found much on this forum, but there are some posts at Elysiun. I'll try asking the question there.