Skip to main content
gamedev.net
🔒 Locked

View Frustrum

Started by TheLabRat Oct 24, 2000 at 10:45 AM 1 replies 500+ views
Original Post
TheLabRat
TheLabRat
What is a good way to check if a vertex is inside the view frustrum, after all rotations and translations are complete. Given : world coordinates of vertex position of camera Rotation of camera Size of view frustrum - depth and field of view Thanks Chris
Friday13
Friday13
Suppose your object''s coords in camera space are Cx,Cy,Cz and suppose you can put the object inside a sphere with radius Cr and center at Cx,Cy,Cz.

So, if (Cz+Cr)zFar, then the object''s outside of the near/far clipping planes.

If this test passes, then:

Suppose you make a projection of Cx,Cy,Cz to the screen getting some Sx,Sy, and you also calculate a projection of the radius Cr, such that it''s originated from Cx,Cy,Cz and is parallel to the projection plane, thus getting some Sr.
Then, if any of the four points (in screen space):
1. Sx-Sr,Sy-Sr
2. Sx+Sr,Sy-Sr
3. Sx+Sr,Sy+Sr
4. Sx-Sr,Sy+Sr

lies within the visible part of the screen, you can consider
the object to be roughly inside the viewing frustrum.

This is a rough method, but it''s very fast.
Friday13
Friday13
Damn, I completely forgot about html tags...

The string

>So, if (Cz+Cr)zFar, then the object''s outside of the near/far clipping planes

should have read:

if (Cz+Cr) LESS than zNear OR (Cz-Cr) GREATER than zFar, then the object''s outside of the near/far clipping planes.

Sorry.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.