Archived

This topic is now archived and is closed to further replies.

Elaboratus

Determining "On Screen" Quickly?

Recommended Posts

Can anyone tell me if there is a fast way to determine if a mesh/object/point is on screen without screen-resolution n x n raycasting? Right now I''m using really elaborate ways of determining if something is visible and its kind of sloppy. Any ideas on determining if something is in the view?

Share this post


Link to post
Share on other sites

As mentioned above, search the archives here, it''s come up a few times in each of the forums here.

One of the simplest and quickest methods is a "shere in cone" test. It is however less precise, you get more false trivial-accepts.

Basically you calculate a bounding sphere for every object in the scene (i.e a position and a radius).

You then calculate a cone which represents the view frustum (the axis of the cone is the direction the camera is looking, the base and apex are the far/near clipping planes and the sweep angle is the field of view).

Then with a simple bit of maths you can determine whether the sphere is inside or outside of the cone, if it''s outside, then the object is definately not visible on the screen. If the sphere is inside or touches the edge of the cone, then the object is potentially visible on the screen.

In many situations this is enough culling, unless you have *lots* of objects or lots of thin objects which don''t fit in the sphere well. The beauty of using bounding volumes is an object could have 200000 polygons but you only do a single sphere->cone test to determine whether it might be visible.

If the object does have a lot of polys and is determined to be potentially visible by the test, you can then go down to finer grained methods (kd-trees, Octrees, BSP, brute-force etc). The point is you save lots of work when objects are definately not visible.


BTW: when searching, you might want to look for both "frustum" and "frustr um", many people accidentally spell it the second way (it shouldn''t have that last ''r'').

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites