PDA

View Full Version : question related to frustum culling

candy
01-18-2004, 05:45 PM
Hi all, I have one question related to frustum culling. I know that in order to implement the frustum culling on the generation of terrain, it is better if we use bounding box / sphere for testing if it is in the viewing frustum. What my question is for the bounding box / sphere, we do probrbly need to specify the center and the radius, but how do we calculate the center? Add up all the vertices and find out their average?

Thx all

mogumbo
01-18-2004, 05:57 PM
You need the median, not the average. Find the highest and lowest x, y, and z values. Then average those to get the center.

candy
01-18-2004, 07:45 PM
Sorry, you mean that I just need to find the average between the highest point of coordinate and the lowest point of coordinate is ok?

candy
01-22-2004, 04:52 PM
I just wonder, in the game world, the terrain suppose to be very large, let say 50000 x 50000 for instance, if we need to loop and go through all the vertices to find out the largest and the smallest and then average them, it will probably slow down the process i think, is that i have something misunderstood?

Thanks a lot

01-22-2004, 05:43 PM
Yes, you want to find the center of the vertices, not their average position. As
mogumbo says, average the highest and lowest values for each axis.

And yes, if you have a large number of points this is going to take a certain amount of time, if you need to keep recalculating it - but that's your call. There are many ways to deal with this kind of problem - maybe you could change the data structure of your points such that you always know which are the furthest along each axis?

01-22-2004, 05:47 PM
Oh, and another consideration:

If your engine is designed to run at a decent speed with this terrain in view, maybe there's no point in frustum culling it... Maybe the time you'll save will just be sucked up in a vsync anyway?

Again, this is your call - you know your requirements better than anyone else.

candy
01-22-2004, 05:59 PM
Hi, Thanks a lot for your help! I think I get what you mean. But would you mind listening to me once more so that I won't misunderstand you guys meaning? Thanks.

Is that I should for instance, store the x, z (as y-axis for the height of the terrain) dimension (say x=50000, z=50000 in my previous example) Then I should average then ie. x = z = (0+50000)/2 here. And it is the center of the bounding box, right?
And that's it?

And is that people usually would use quad tree instead of octree here?

Thx a lot