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. 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?
Also, apparently, there used to be a bug in 2.32 with names of IPO’s that required scripts to do some weird tricks in order to get the bone locations for each frame. Is this still required in 2.33?