Jump to content
  • Advertisement
Sign in to follow this  

how to get comboMatrix for frustum culling

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

How can i get the comboMatrix for fructum culling. I need it to extract the 6 planes. i have read some frustum culling articles but they just mention that i need the comboMatrix. Can i get the comboMatrix by multiplaying the view matrix with the projection matrix? e.g. D3DXMatrixMultiply( &matCombo, &matView, &matProj); please help me~ [Edited by - fantasyz on July 2, 2006 8:06:11 PM]

Share this post

Link to post
Share on other sites
Yeah, that should do the trick - you've then got to be careful about clipping your post-transformed geometry (that is, factor in your "world matrix")...

I'm pretty sure this code should work, and it does similar to what you're describing:
void ObjCuller::UpdateCullArea(D3DXMATRIXA16 *matView, D3DXMATRIXA16 *matProj) {
//use 4 main steps to calculate the frustum planes

//0. Variables:
//D3DXVECTOR3 vecFrustum[8];

//1. multiply the matrices together
D3DXMatrixMultiply( &mat, matView, matProj );
D3DXMatrixInverse( &mat, NULL, &mat );

//2. create the 8 points of a cube in unit-space
vecFrustum[0] = D3DXVECTOR3(-1.0f, -1.0f, 0.0f); // xyz
vecFrustum[1] = D3DXVECTOR3( 1.0f, -1.0f, 0.0f); // Xyz
vecFrustum[2] = D3DXVECTOR3(-1.0f, 1.0f, 0.0f); // xYz
vecFrustum[3] = D3DXVECTOR3( 1.0f, 1.0f, 0.0f); // XYz
vecFrustum[4] = D3DXVECTOR3(-1.0f, -1.0f, 1.0f); // xyZ
vecFrustum[5] = D3DXVECTOR3( 1.0f, -1.0f, 1.0f); // XyZ
vecFrustum[6] = D3DXVECTOR3(-1.0f, 1.0f, 1.0f); // xYZ
vecFrustum[7] = D3DXVECTOR3( 1.0f, 1.0f, 1.0f); // XYZ

//3. transform all 8 points by the view/proj matrix. Doing this
// gives us that ACTUAL 8 corners of the frustum area.
for( int i = 0; i < 8; i++ )
D3DXVec3TransformCoord( &vecFrustum, &vecFrustum, &mat );

//4. generate and store the 6 planes that make up the frustum
D3DXPlaneFromPoints( &FrustumPlanes[0], &vecFrustum[0],
&vecFrustum[1], &vecFrustum[2] ); // Near

D3DXPlaneFromPoints( &FrustumPlanes[1], &vecFrustum[6],
&vecFrustum[7], &vecFrustum[5] ); // Far

D3DXPlaneFromPoints( &FrustumPlanes[2], &vecFrustum[2],
&vecFrustum[6], &vecFrustum[4] ); // Left

D3DXPlaneFromPoints( &FrustumPlanes[3], &vecFrustum[7],
&vecFrustum[3], &vecFrustum[5] ); // Right

D3DXPlaneFromPoints( &FrustumPlanes[4], &vecFrustum[2],
&vecFrustum[3], &vecFrustum[6] ); // Top

D3DXPlaneFromPoints( &FrustumPlanes[5], &vecFrustum[1],
&vecFrustum[0], &vecFrustum[4] ); // Bottom
} //UpdateCullArea()


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!