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

## 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 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:
D3DXMATRIXA16 mat;
//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()

hth
Jack

thankyou~

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 12
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633314
• Total Posts
3011323
• ### Who's Online (See full list)

There are no registered users currently online

×