when using
Vector3f[] vertices = new Vector3f[mesh.getVertexCount()];
mesh.getMeshAsTrianglesVertices(vertices);
how do I apply the local rotation of the spatial to each vertex?
when using
Vector3f[] vertices = new Vector3f[mesh.getVertexCount()];
mesh.getMeshAsTrianglesVertices(vertices);
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.
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);