Jump to content
  • Advertisement
Sign in to follow this  
mrheisenberg

DirectXCollision BoundingFrustum usage?

This topic is 1789 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

I got my DirectXMath-using camera to compute view and projection matrices properly, however when using DirectXCollision structures I ran into some problems.When I frustum cull, everything is always culled away.Here is what I do:

-Build a projection matrix
-Build a frustum from that projection matrix with BoundingFrustum::CreateFromMatrix
-Transform the frustum by the view matrix that is generated each frame

-Each screen object has a BoundingSphere that is transformed by it's world matrix each frame

-Each frame I test if entities intersect frustum and if they don't, they aren't rendered.

Is this the proper usage?

Share this post


Link to post
Share on other sites
Advertisement

Would be faster and more reliable to extract from the view-projection matrix directly rather than transforming the frustum by the view matrix.

 

Otherwise if your objects are not being drawn then you need to use a debugger and verify the bounding spheres etc.  You should create a test case in which it is clear when an object is inside, colliding with, or outside the frustum.  If the return values are always exactly opposite then the normals on your frustum are reversed (but I don’t know how that could happen if you only use their math functions).

 

 

L. Spiro

Share this post


Link to post
Share on other sites

It's weird, objects flicker on the screen while debug output stays at "Objects on screen: 2", is it certain that the frustum must be transformed by the camera's view matrix?Or is it something else?

Share this post


Link to post
Share on other sites

If you define the view matrix as the inverse of the camera’s world matrix, then passing the projection matrix to BoundingFrustum::CreateFromMatrix() and transforming that by the view matrix is the same as just calling BoundingFrustum::CreateFromMatrix() with the view-projection matrix except a million times slower.  I would call BoundingFrustum::CreateFromMatrix() on the view-projection matrix just for stability more than anything, since that is what is generally used to create a frustum from a matrix.

 

 

If you want to eliminate that as a factor, why don’t you keep the camera on identity and move the objects around?

 

 

L. Spiro

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!