Quote:modelX/Y/Z do the reverse, screen->world.. exccept they don't exactly map.. they go to some internal half-way values instead.
It is possible to work out the bounds of the view frustrum, but it's a right pain in the arse.
no, modelX/Y/Z give you the coordinates in model space. this is the coordinates of the object after any user-specific translate/rotate/scale, but before the camera settings have been applied to manipulate the points. i just noticed that the reference on this has not been written, i'm guessing either casey asked me to and i haven't yet, or i did at some point and we forgot to update it, sorry.
to get the view coordinates, you can look at the source of PGraphics3D. since you're looking for the frustum, you might try searching for the text 'frustum', which turns up the 'frustum' function. working backwards from that, you can see it gets called from perspective():
Code:
public void perspective(float fov, float aspect, float zNear, float zFar) {
float ymax = zNear * tan(fov / 2.0f);
float ymin = -ymax;
float xmin = ymin * aspect;
float xmax = ymax * aspect;
frustum(xmin, xmax, ymin, ymax, zNear, zFar);
}
so those are the coords for the viewing frustum. this perspective() function is called from the overloaded no args version:
Code:
public void perspective() {
perspective(cameraFOV, cameraAspect, cameraNear, cameraFar);
}
searching for cameraFOV et al turns up the resize() method, in which you'll find:
Code:
cameraFOV = 60 * DEG_TO_RAD; // at least for now
cameraX = width / 2.0f;
cameraY = height / 2.0f;
cameraZ = cameraY / ((float) tan(cameraFOV / 2.0f));
cameraNear = cameraZ / 10.0f;
cameraFar = cameraZ * 10.0f;
cameraAspect = (float)width / (float)height;
now you can frustum with the best of em.