Apply rotation to vertex

when using

Vector3f[] vertices = new Vector3f[mesh.getVertexCount()];
mesh.getMeshAsTrianglesVertices(vertices);


how do I apply the local rotation of the spatial to each vertex?

What is the use case for rotating the vertex itself ?

Don't you want to rotate the whole spatial ?

The whole spatial is already rotated with setLocalRotation. But when I get the vertices's they are in its original position. I am projecting them to the screen so I can draw a box around a spatial.



Ive got the box drawing fine, except when the spatial is rotated…









Never mind, I got

v = getLocalRotation().toRotationMatrix().mult(v);

You could also try projecting the bounding box to the screen, as projecting every vertex every frame could reduce performance.

Momoko_Fan said:

You could also try projecting the bounding box to the screen, as projecting every vertex every frame could reduce performance.


How would I do that? Would I need to get the vertices's of the bounding volume?

You just add or subtract the x/y/z extents from the center to get the coordinates.

E.g:


BoundingBox bbox = (BoundingBox) spatial.getWorldBound();
Vector3f vert1 = bbox.getCenter().add(bbox.xExtent, bbox.yExtent, bbox.zExtent);