# 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.

## Recommended Posts

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

##### Share on other sites
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 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 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 on other sites
Quote:
 Original post by OpwizHm.. 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 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 on other sites
Quote:
 Original post by OpwizHm, there is a difference between checking if frustum is inside a quad versus checking if quad is inside (or intersecting) the frustum.

I dont see the difference.

##### Share on other sites
Check out Mark Morley's frustum culling tutorial. I found it to be very clear and extremely helpful, but then his site just went down. I managed to save a copy from the google cache. Does anyone know what happened to him?

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002291
×