Sign in to follow this  

Help with view frustum

This topic is 4480 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[p].a * pt.x + viewFrustum[p].b * pt.y + viewFrustum[p].c * pt.z + viewFrustum[p].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

This topic is 4480 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this