# Help with view frustum

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

## 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 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 on other sites

http://www.ce.chalmers.se/~uffe/vfc.pdf

##### Share on other sites
Research on the web, that's where I learnt how to do what you are asking. Try www.gametutorials.com.

##### Share on other sites
All that info was very useful, specially about getting the frustum planes. Thanks a lot.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634136
• Total Posts
3015757
×