PDA

View Full Version : Frustum culling problem

HemiMG
11-03-2001, 01:34 AM
I found a tutorial on frustum culling in OpenGL and tried to implement it. One function extracts the frustum, I'll assume that one works for now(should the D value for each plane be ALOT higher than the other three? usually the other three are one or so and the last is 256 or so.)
Anyhow assuming that one works the next function tests for a cube in the frustum.
It works like so:

for(i=0li<6;i++)
{
if ((F[i][0]*x) + (F[i][1]*y) + (F[i][2]*z) + F[i][3]) > 0)
continue
//repeat that for every point in the box
return false
}
return true

(I'm sorry if that doesn't show up to well, there is no preview button)
Anyhow the problem is that no point make it through there. Am I doing something wrong? I'm tired of staring at a 3dfx logo because that function doens't let any points through! http://www.opengl.org/discussion_boards/ubb/smile.gif

jabe
11-03-2001, 04:36 AM
it depends on your implementation. what does a positive distance from the plane mean? ok, the point is in front of the plane, but in which direction are the planenormals pointing, into the viewfrustum or away from it?

if they point away (mostly the case), the distance has to be negative (<0).
so try to change your if-clause.

regards,
jan

11-03-2001, 04:07 PM
Just to add a little to the last reply. Try placing the camera close th the origin. Under these conditions the value of D should be close to zero. Or more precisely d/sqrt(A*A+B*B+C*C) should be small. If not, you are calculating your D incorrectly.

HemiMG
11-03-2001, 04:14 PM
I figured it out, it was just an error on my part. I am loading a Quake I bsp and of course the coordinate system is different, I had the wrong signs in my conversion.