however I am not sure how to use this vertex index.
is it a direct index into me.vertices? (I sure hope it is)
Please note that I triangulate the mesh before I export it. I keep the vertex order though, so it should be the same.

Here's what I'm planning to do:
My file format has a new kind of line:

vc f f f

and it modifies the f lines:

f position/uv/norm/skel position/uv/norm/skel position/uv/norm/skel

the vc lines were originally designed to hold color information like this

#Solid red
vc 1.0 0.0 0.0
#Solid green
vc 0.0 1.0 0.0

However I realized that this exact same system could contain skeletal animation information.
Here are the steps:

In order for this to work, I need to figure out how much each vertex (3D point, with X, Y, and Z) is weighted by each bone, pick the top 3 per vertex (and if there aren't 3, stick in a fake 0 bone with 0 weight for every missing spot) and write it to file in VC lines.
If I do this for every 3d point, then I can simply use the same indices as the positions for the f lines.

f A/B/C/A

How could I achieve this?

I assume that there is only one armature in the scene called 'Armature' and that the only mesh currently being exported (But not necessarily the only one in the scene) is influenced by it.

I have access to the list of Objects to be exported, so I can access both the triangulated mesh from bpy.data.meshes[] and the object from bpy.data.objects[]

1 Answer
1

The objects data property contains the data used to define the objects appearance. For a mesh object that includes vertices, edges and polygons.

While vertex groups are stored within an objects properties, each groups vertex indices are direct indices into the objects data.vertices[] list. These are all kept in sync internally by blender so you don't have to be concerned, unless the mesh gets edited while you are accessing the data.

If you start with bpy.context.selected_objects you can export objects of type MESH. Then look at an objects modifiers list to find a modifier with a type of ARMATURE and get the object property from that to get the relevant armature.