[SOLVED]Get current world translation of a mesh vertex?

Is there a way to get the world translation of a vertex that was read from the vertex buffer of a mesh?

My first thought was to add the sum of the local translations of all of the parents, but I don’t think that would take into account any displacement due to parent rotations.

My second thought was to attach a dummy spatial to the first parent spatial of the mesh, then set it’s local translation to the position of the mesh vertex, all just to call it’s getWorldTranslation() method. Seems like a cheap hack, even if I only attach one dummy spatial and reuse it for each vertex in the mesh.

My third thought was to post here for suggestions, maybe there is a hidden util for this.

Any suggestions/critique?

1 Like

If you also have access to the geometry for that mesh, then I think something like this should work, using the transformVector() method with the geometry’s WorldTransofrm

   Transform transform = geometry.getWorldTransform();
   Vector3f worldSpaveVert;

    transform.transformVector(modelSpaceVertFromBuffer, worldSpaceVert);

https://javadoc.jmonkeyengine.org/com/jme3/math/Transform.html#transformVector-com.jme3.math.Vector3f-com.jme3.math.Vector3f-

1 Like

Vector3f w = geom.localToWorld(theVertex);

https://javadoc.jmonkeyengine.org/com/jme3/scene/Spatial.html#localToWorld-com.jme3.math.Vector3f-com.jme3.math.Vector3f-

1 Like

I never thought to look into Geometry, thanks @pspeed and @yaRnMcDonuts!