Whats wrong with my frustum cullinh code?
Ive used the code bellow for my frustum culling test and it doesnt work
Matrix proj = new Matrix( );
Matrix view = new Matrix( );
proj = device.GetTransform( TransformType.Projection );
view = device.GetTransform( TransformType.View );
Matrix comboMatrix = Matrix.Multiply( proj, view );
#region Plane extraction from combo matrix
//extract left plane
frustum[ 0 ].A = comboMatrix.M14 + comboMatrix.M11;
frustum[ 0 ].B = comboMatrix.M24 + comboMatrix.M21;
frustum[ 0 ].C = comboMatrix.M34 + comboMatrix.M31;
frustum[ 0 ].D = comboMatrix.M44 + comboMatrix.M41;
frustum[ 0 ].Normalize( );
//extract right plane
frustum[ 1 ].A = comboMatrix.M14 - comboMatrix.M11;
frustum[ 1 ].B = comboMatrix.M24 - comboMatrix.M21;
frustum[ 1 ].C = comboMatrix.M34 - comboMatrix.M31;
frustum[ 1 ].D = comboMatrix.M44 - comboMatrix.M41;
frustum[ 1 ].Normalize( );
//top clipping plane
frustum[ 2 ].A = comboMatrix.M14 - comboMatrix.M12;
frustum[ 2 ].B = comboMatrix.M24 - comboMatrix.M22;
frustum[ 2 ].C = comboMatrix.M34 - comboMatrix.M32;
frustum[ 2 ].D = comboMatrix.M44 - comboMatrix.M42;
frustum[ 2 ].Normalize( );
//bottom clipping plane
frustum[ 3 ].A = comboMatrix.M14 + comboMatrix.M12;
frustum[ 3 ].B = comboMatrix.M24 + comboMatrix.M22;
frustum[ 3 ].C = comboMatrix.M34 + comboMatrix.M32;
frustum[ 3 ].D = comboMatrix.M44 + comboMatrix.M42;
frustum[ 3 ].Normalize( );
//near clipping plane
frustum[ 4 ].A = comboMatrix.M14 + comboMatrix.M13;
frustum[ 4 ].B = comboMatrix.M24 + comboMatrix.M23;
frustum[ 4 ].C = comboMatrix.M34 + comboMatrix.M33;
frustum[ 4 ].D = comboMatrix.M44 + comboMatrix.M43;
frustum[ 4 ].Normalize( );
//Far clipping plane
frustum[ 5 ].A = comboMatrix.M14 - comboMatrix.M13;
frustum[ 5 ].B = comboMatrix.M24 - comboMatrix.M23;
frustum[ 5 ].C = comboMatrix.M34 - comboMatrix.M33;
frustum[ 5 ].D = comboMatrix.M44 - comboMatrix.M43;
frustum[ 5 ].Normalize( );
and i test my a certain Point using this code:
public static bool CheckPoint( float x,float y,float z )
{
for(int i= 0; i < 6 ; i++ )
{
float d = frustum.A* x + frustum.B*y +
frustum.C* z + frustum.D;
if( d <= 0 ) return false;
}
return true;
}
whats wrong with my code?
[Edited by - Coder on November 9, 2004 2:44:27 AM]