Mesh getTriangle using hardware skinning

I am using getTriangle from the Mesh to get the position of the triangle during an animation. Which works fine using software skinning, but when I switch to hardware skinning it gives me always only the position from the rest pose. I assume because the index buffers are modified on the GPU only when using hardware skinning.

So my question is if there is any way to get the correct triangle position even when using hardware skinning?

Well… to be a bit pedantic, the index buffer is never modified, neither in software nor hardware skinning.
Position, Normal and Tangent buffers are modified in software skinning. In hardware skinning, the buffer themselves are never modified, we just send the transforms to the shader and the transformation occurs int he vertex shader.

So to answer your question, to get a triangle real position when using hardware skinning, you need to transform the positions with the frame transforms.
For this you need to get the bone(s) that is influencing the vertices, by fetching the boneIndex buffer on the mesh (matches vertex index with bone index).
Then to get the bone transforms you can use the computeSkinningMatrices method of Skeleton (the animControl and the SkeletonControl both hold a reference to the skeleton).
This method returns the transforms of each bone of the skeleton for this frame. Pick the one of the bone you got from the boneindex buffer and apply it to your vertices pos.

1 Like

Ofc - not the index buffer :wink:

Thanks for the answer! This was also what I was thinking, transform the triangle position using the bone weights. Just thought there might be a better approach…