Jump to content
  • Advertisement
Sign in to follow this  
Hibbs

Frustrum Bounding Volume

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

Can anyone help me with calculating a Frustrum Bounding Volume, or obtaining the four corner vertex's. Im using directx. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Aren't there 8 corner vertices?

But anyway assuming you do mean 8 and not 4 it's done as follows (well, I'm an OpenGL man but here's how I think it works in D3D): take your 3 matrices (world, view and projection), multiply them together in order (i.e. work out the overall transformation matrix), and then invert it. Then transform 8 vertices through that which are all the combinations of (-1/+1,-1/+1,-1/+1). This will give you the 8 points in world space. Which is which depends on whether you're using a left- or right-handed coordinate system (I seem to remember most D3D apps use left-handed in defiance of hundreds of years of science and maths, but I could well be wrong), and the matrix inversion will be different to OpenGL because the matrices are stored differently. If you want the viewer position, transform the vector (-1, 0, 0, 0) through that matrix.

Share this post


Link to post
Share on other sites
Finding the clipping planes didnt help me much becuase i want to check the frustrum volume against my octree & the clipping planes tell me if a point isnt in the frustrum where-as I want to check to see if the frustrum is inside a quad.

I coded up to find the eight points of the frustrum and created a virtual camera(world view projection) so that I could render it all on the screen. It draws a frustrum shaped pyramid on the screen :) - but changing the world matrix moves it in the opposite direction - obviously becuase of the invert - removing the invert and i dont get a pyramid frustrum. Inverting the world matrix before the multiplication works. Is this a correct behaviour?

Added: Somthing is deffinatley wrong, changing the farPlane increases the size of the frustrum but also moves its posiition. Am I multiplying the matrix's in the correct order?

Heres my code:

Matrix p = Matrix.PerspectiveFovLH((float)Math.PI / 4, 1, 1.0f, 2.0f);
Matrix v = Matrix.LookAtLH(new Vector3(0, 0, 0), new Vector3(0, 0, 2), new Vector3(0, 1, 0));
Matrix m = Matrix.Translation(-3, -1, -3);
Matrix M = m * v * p;
M.Invert();

fv[0] = new Vector3(-1, -1, -1);
fv[1] = new Vector3(1, -1, -1);
fv[2] = new Vector3(1, 1, -1);
fv[3] = new Vector3(-1, 1, -1);
fv[4] = new Vector3(-1, -1, 1);
fv[5] = new Vector3(1, -1, 1);
fv[6] = new Vector3(1, 1, 1);
fv[7] = new Vector3(-1, 1, 1);

for (int i = 0; i < 8; i++)
{
fv.TransformCoordinate(M);
}

Thanks

Share this post


Link to post
Share on other sites
Hm.. I'm not sure exactly why you would want to check if a frustum is in a quad or not. Normally if you want to perform frustum culling with an octree you check if the quad is inside, intersect or outside the frustum. If the quad is outside you can assume that all sub-quads are too, if inside you could assume that all sub-quads are inside, if intersecting you should perform intersection tests on the sub-quads.

Share this post


Link to post
Share on other sites
Quote:
Original post by Opwiz
Hm.. I'm not sure exactly why you would want to check if a frustum is in a quad or not. Normally if you want to perform frustum culling with an octree you check if the quad is inside, intersect or outside the frustum. If the quad is outside you can assume that all sub-quads are too, if inside you could assume that all sub-quads are inside, if intersecting you should perform intersection tests on the sub-quads.


Why do you see a distinction between the two checks?

Share this post


Link to post
Share on other sites
Hm, there is a difference between checking if frustum is inside a quad versus checking if quad is inside (or intersecting) the frustum.

Share this post


Link to post
Share on other sites
Quote:
Original post by Opwiz
Hm, there is a difference between checking if frustum is inside a quad versus checking if quad is inside (or intersecting) the frustum.


frustum inside quad == quad outside frustum

I dont see the difference.

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!