Jump to content
  • Advertisement
Sign in to follow this  

Help with view frustum

This topic is 4816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Maybe this question was asked a lot :o How can I get if an object is inside the view frustum? For example: I have a box, and while I move the camera, I want to know if the box is inside the frustum or not. Thanks.

Share this post

Link to post
Share on other sites
I think your the 4th this week (my self included) :)

Basically your frustum is made up of 6 planes that all face inward, so we simply find the distance of a point (pt) to each plane. If any are negative then the point must be outside of the frustum.

int p;
for( p = 0; p < 6; p++ )
if( viewFrustum

.a * pt.x + viewFrustum

.b * pt.y + viewFrustum

.c * pt.z + viewFrustum

.d <= 0 )
return NEGATIVE;
return POSITIVE;

If you don’t have those 6 planes then you need to construct them each frame.
You can find more GL related info here

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!