Hello Guest

Quick method for determining if something is on screen?

  • 5 Replies
  • 7011 Views
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

Quick method for determining if something is on screen?
« Reply #1 on: July 18, 2006, 07:06:27 »
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

Quick method for determining if something is on screen?
« Reply #2 on: July 18, 2006, 15:10:03 »
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

Quick method for determining if something is on screen?
« Reply #3 on: July 18, 2006, 17:11:35 »
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.

hmmmmm...
« Reply #4 on: July 18, 2006, 17:12:40 »
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

Quick method for determining if something is on screen?
« Reply #5 on: August 05, 2006, 00:53:08 »
Look @ here, he uses some functions that might interest you.