Quick method for determining if something is on screen?

Started by elias4444, July 17, 2006, 19:04:01

Previous topic - Next topic

elias4444

I'm working on optimizing my game, and was wondering if there was a quick/easy way to determine if an object is viewable on screen or not (to determine if it should be drawn or not). I know culling can determine if a face is forward facing or not, but is there another method for determining if something is within the viewport?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

funsheep

how about object-culling with
-(loose-)octrees
-bsp-trees
-scenegraphs
-just a list with all objects, making a frustum-culling-test against their boundingbox (the trees do the same, only with less tests)
?

regards
funsheep

elias4444

My main issue is just trying to come up with some sort of math that determines if something is "on-screen" or not. This isn't an orthographic game, so it gets a bit complicated. I'm at a loss as to how to determine it.  :(
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

funsheep

regardless which type of rendering you use, you always have some sort of viewfrustrum. which can be a box, a frustrum of pyramid (in a usual 3D game), a 2D rectangle in a 2D game, etc. the type of your frustrum is determind by the projectionmatrix.

now you can use your frustrum culling it with the boundingbox of your objects (in 2D for example a 2D rectangle, in 3D a 3D box, or a 3D sphere).

if your frustrum intersects the boundingbox of the object, the object or a part of it is visible - "on screen".

look for some tutorials, how to compute the intersection of a frustrum and a box or whatever.

http://www.realtimerendering.com/int/ here you can find an overview over some intersection computations and where they are listed.

Fool Running

you need to do Frustum-culling (like funsheep said :D ) to determine if a 3D object is in the view frustum. You should be able to search Google to find examples on how to do this.

EDIT: Nevermind, Funsheep beat me :lol:
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Rasengan

Look @ here, he uses some functions that might interest you.