I’m trying to find the 8 corners of my view frustum by using Camera.getWorldCoordinates, but it doesn’t seem to use zPos correctly. Everything I’ve found says use 0 for the near plane and 1 for the far plane. But 0 and 1 return identical results:
Vector3f nearBottomLeft = cam.getWorldCoordinates(
new Vector2f(0, 0), 0);
Vector3f nearBottomRight = cam.getWorldCoordinates(
new Vector2f(cam.getWidth(), 0), 0);
Vector3f nearTopLeft = cam.getWorldCoordinates(
new Vector2f(0, cam.getHeight()), 0);
Vector3f nearTopRight = cam.getWorldCoordinates(
new Vector2f(cam.getWidth(), cam.getHeight()), 0);
Vector3f farBottomLeft = cam.getWorldCoordinates(
new Vector2f(0, 0), 1);
Vector3f farBottomRight = cam.getWorldCoordinates(
new Vector2f(cam.getWidth(), 0), 1);
Vector3f farTopLeft = cam.getWorldCoordinates(
new Vector2f(0, cam.getHeight()), 1);
Vector3f farTopRight = cam.getWorldCoordinates(
new Vector2f(cam.getWidth(), cam.getHeight()), 1);
log.log(Level.INFO, "NBL {0}, NBR {1}, NTL {2}, NTR {3}, FBL {0}, FBR {1}, FTL {2}, FTR {3}",
new Object[]{nearBottomLeft, nearBottomRight, nearTopLeft, nearTopRight,
farBottomLeft, farBottomRight, farTopLeft, farTopRight});
gives:
INFO: NBL (-0.5522847, -0.41421354, 9.0), NBR (0.5522847, -0.41421354, 9.0), NTL (-0.5522847, 0.41421354, 9.0), NTR (0.5522847, 0.41421354, 9.0), FBL (-0.5522847, -0.41421354, 9.0), FBR (0.5522847, -0.41421354, 9.0), FTL (-0.5522847, 0.41421354, 9.0), FTR (0.5522847, 0.41421354, 9.0)