View Full Version : Clipping planes
02-16-2000, 01:23 PM
I'd like to add some rough view-frustum clipping to my terrain renderer. The problem is: how can I get the 6 standard clipping planes coefficients?
I have two ideas:
first, calculate them as if I were in the origin lookin down the z-axis (default), then use the current modelview matrix to transform them correctly.
Second: I don't know, maybe there's a way to ask OpenGl about them, or another way to do frustum clipping.
why don't use frustum bounding sphere instead of frustum planes?
maybe is better, since with a single test you can see if polygon or object is near the frustum...
Use glFrustum. Specs for example at http://www.eecs.tulane.edu/www/graphics/doc/OpenGL-Man-Pages/opengl_index_alpha.html
02-17-2000, 09:04 AM
I mean I'd like to clip objects before sending them to the rendering queue. I could consider the idea of using spheres, but I still need to take into account the planes that define the view frustum.
Ohh... Then you have to make your own frustum calculations. I guess you can't directly access the OpenGL clipping planes.
fovy = vertical fov
aspect = aspect ratio (width/height)
nearz = distance from near clipping plane
farz = distance from far clipping plane
sy = sin(fovy*0.5)
cy = cos(fovy*0.5)
sx = aspect*sy
cx = aspect*cy
plane = (sx, 0, cx, 0)
plane = (-sx, 0, cx, 0)
plane = (0, -sy, cy, 0)
plane = (0, sy, cy, 0)
plane = (0, 0, 1, znear)
plane = (0, 0, -1, zfar)
This is the frustum in view space. If you want to do clipping in object space, you need to transform the frustum into object space first.
For this you need to transform the plane normals into object space. You also need some points on the planes, so transform eye point (0, 0, 0), near point (0, 0, znear) and far point (0, 0, zfar) into object space. Then calculate the plane equations.
So, you need to implement all this matrix stuff etc. yourself.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.