PDA

View Full Version : glOrtho, zNear and zFar



jmikhael
07-23-2003, 05:30 AM
Can anyone explain what the zNear and zFar parameters in glOrtho should be? I am developing a 3D modeling environment, so models may not always be centered about the origin. When I frame the view to show the entire model, I redefine the projection with glOrtho using the center of the data and the radius of the bounding sphere so that my glOrtho parameters become:

left = centerX - radius
right = centerX + radius
top = centerY + radius
bottom = centerY - radius
near = centerZ + radius
far = centerZ - radius

However, when I send these parameters into glOrtho portions of the model get clipped as I rotate about the center of the data. I've had to increase the radius by a factor of 5 to keep this from happening, but then the precission of the depth buffer goes down more than it should. Should I be defining the near and far parameters differently?

abhijeet_maharana
07-24-2003, 01:11 AM
What is seen on the screen is also dependent on the position of your camera. What u have suggested seems to be correct. Also u could try placing your camera a bit far away so that u have the entire scene in your view frustum.

Mazy
07-24-2003, 02:04 AM
I guess you translate the camera in order to see the object in front of you..

then the znear/zfar must be translated as well, if you move 10 steps back you should move the planes 10 steps forward.

jmikhael
07-24-2003, 03:05 AM
Yes, the camera has been translated and rotated with gluLookAt to see the scene. I define my clipping planes in terms of world coordinates. Should I be using eye coordinates instead?