I want to render skinned animated meshes without using matrix palettes
(not to improve performance, but to enable skinning on more mobile devices).
Therefor I have to transform the vertices and normals with the according
bone matrix by hand at cpu level.
My current approach would be to compute the bone matrices for the entire
model and store them in a matrix vector. In a second pass I would run
through the whole interleaved vector and multiply each vertex and normal vector
with the according matrix.
For doing so I need the mapping between the vertex data and the according bone/weight. As far as I understood the bone indices refer to the matrix palette of
the current bone batch and not to the node index of the bone or am I confusing something?
Any hint about how to interprete the direct mapping of vertices and bone nodes in
the pod file would be appreciated.
If you want to do software skinning then you are much better off exporting your models without bone batching altogether.
Actually, looking at the code again … you can easily map bone indices to POD nodes by iterating over
pnBatches member of the CPVRTBoneBatches class.
These values map directly into pod node index.
Someting like this:
nodeid = mesh->sBoneBatches.pnBatches[currentindex];
and then :
SPODNode *node = &scene.pNode[nodeid ];
where the SPODNode instance is a logical equivalent of your single matrix in the array.
so what I’ll do is to create a cached mapping for each bone batch and its associated triangles into the interleaved vertex vector. Then the “currentindex” from the bone index should map correctly into my cpu matrix palette computed from for each bone.
Yeah, but as I said, if you are doing software skinning then , if you can help it , make sure that whatever exporter you are using , is putting all bones into a single batch.
Since you are not using GPU hardware you are not bound by its limitations and there is no need to create multiple batches because that will only slow you down.