I’m working on view frustum culling, and I’ve hit a dead end. What I have so far, are six planes derived from the opengl projection and modelview matrices. (Following this tutorial: http://www.crownandcutlass.com/features/technicaldetails/frustum.html) What I assumed is that the frustum would move with camera due to the translations I’m doing. Nope, it just sits there at 0 0 0 looking down the z axis. How do I make it move with the camera?
Which z-axis? Are referring to the world z-axis? or the local z-axis of the camera? A frustum is attached to the camera, so it should always be at (0, 0, 0) looking down the z-axis if you’re in the camera’s coordinate space.
If you’re referring to the world or model space, and the frustum is staying at (0, 0, 0) (which would imply that it movies on screen when you move the camera), then its likely that you’re setting the MODELVIEW matrix at the wrong time. Although I haven’t carefully read that tutorial, you’ll likely want to set the MODELVIEW matrix to the ‘view’ part of the model-view transform just before you compute your frustum. Related to this, you must remember to re-read the MODELVIEW matrix every frame because your translation will be changing it.
Right, I meant the world z-axis. THANK YOU! You pointed me in the right direction and I’ve managed to fix it. The main issue was adding
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
right before I compute the frustum, then a call to my my translation code.