   Frustrum Problems
  Hi, I'm working on my frustrum culling stuff, because I was getting some really odd things happening with it.  I set up a second camera so I could see what was and wasn't getting culled, and I was seeing that things obviously within the camera's view were being culled, and things obviously outside were not.After a couple of hours of tweaking and messing with it with no luck, I ended up writing some code to draw a wireframe representation of the frustrum itself from the planes I'm extracting.  What I've found is that the frustrum works perfectly... as long as the camera is exactly at the origin.If the camera position is anywhere else, the near plane (I think) starts showing up very strangely.  Anything from flipping upside down, to becoming perpendicular to the far plane, changing shapes and sizes, really weird stuff.  I'm pretty sure this is the root of my problem.My plane extraction code is identical to every DirectX version I've seen on the internet that all claim to work.  I've checked the values of the planes themselves and they appear to be correct, but obviously something is wrong.Anyone else have this problem?  Or can anyone suggest something else I can try?  I've pretty much run out of ideas after having worked on it all last night and most of today.I can post some screenshots of the frustrum itself along with position and orientation if anyone thinks that will help.   
  Sounds odd, but if you say it only works fine at the origin then I'd hazard a guess that its a mathematical problem - not compensating for one of the transform steps for example.How exactly are you finding the corners of your view frustum? Are you definitely sure this is correct? Not muddling up any LH/RH coordinate system stuff?Are you 110% sure that your debug/visualization of the planes is correct? Unlikely, but always worth checking that you're not debugging the wrong thing [wink]Off the top of my head, ISTR that you need only take the 8 points of the -1..+1 cube and transform them by the inverse of the view*projection matrix to get the real corners of the frustum and you can then use standard plane-from-points (e.g. D3DXPlaneFromPoints()) to generate the 6 planes. Are you doing something differently?I just dug up the following fragment from an old project of mine: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()I had other problems with culling code (I keep meaning to go back and implement a 6-bit cohen-sutherland test [smile]) but I'm pretty sure the above function worked as intended.hthJack   ;  You're actually quite close.  After some more messing around and stepping through every line of code involved, I found out it had nothing to do with my frustrum code at all.  There was a "tiny" bug in my Matrix class that was ignoring the last 2 rows in the last column.  Obviously, bad things happened after that.   