PDA

View Full Version : Select Faces Visible to Camera


russ_c
12-05-2005, 11:56 PM
Is there a way with mel to select all faces in a perspective viewport that are visible to the camera? Maya is already using "occlusion culling" to decide which polygons to draw in the viewport...so how could I go about querying this and selecting all the faces that are not being culled?

Thanks for any help!

Russell

M.E.L.
12-06-2005, 02:00 AM
pretty sure that culling is done with a raycasting pass (cast rays out from the camera, if ray hits face, keep visible, else, cull).

same algorithm could be used to select the faces but from a perspective view it's gonna be a bit trickier and could get REALLY slow tracking about etc.

-s

harmless
12-07-2005, 08:04 PM
To get polys that face the camera:

get the vector of the camera

iterate through all the polys of your mesh

get the dot product of the poly's normal and the camera's vector
the dot will range from 1 to -1 and values that approach -1 are facing the camera
...so you can do something like
float $thresh = .25;
if ($dot >= -1 + $thesh) ...
...add to an array

select the array

If the camera is animated you will just call this code once per frame.
This is not raycasting, but it will return all of the polys facing the camera,
and it will be fast ;)

CGTalk Moderation
12-07-2005, 08:04 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.