I’ve recently implemented an algorithm that needs the world location of a vertex. Currently, I get the vertex local position through the mesh’s position buffer, and then I use geometry.localToWorld(vertexPosition, null) in order to apply the geometry world transform to that vertex. This works well, however the problem I am having now is that since my geometry is affected by a skeleton, the skeletal animations don’t reflect in the geometries world transformations. How would I get the exact world location of my vertex when it as been affected by a bone?
Is it any random vertex or a specific vertex?
Usually for the use-cases I can imagine for a specific vertex you’d instead use an attachment bone and get its world position… not vertexes directly.
This is for a specific vertex. Basically my algorithm requires me to make a ray cast at each of the vertex position of the mesh towards the direction of that vertex normal. I think that I could maybe use an attachment bone in order to get the correct position, but that requires me to look into the bone weight buffer of the mesh and check which bones affect that vertex and by how much. This seems to be a lot of work just to be able to find the world position of the vertex.
You are probably better off using software skinning then. The vertex buffers should be up to date then.
Well I believe I already am using software skinning. When the geometry is loaded I call skeletonControl.setHardwareSkinningPreferred(false). Unless I’m missing something else?
When software skinning is enabled, the vertex buffer itself is modified in CPU… so querying the value from the position buffer should be accurate to local space.
Edit: I’ve used this before myself to make sure that I display an accurate wireframe for a mesh that is animated.
Hmm ok thanks. I’ll see what I can do using this info.