I’m trying to write a non Xith3D program, and am at the point of trying to implement frustum culling. I’ve been looking at lots of online papers and source code. I noticed that the Xith3D code for the perspective calculation appears to be taken from the Mesa source. I also noticed a discrepancy:
public void perspective(float fovy, float aspect, float zNear, float zFar)
{
float sine, cotangent, deltaZ;
float radians = fovy / 2; // * (float)Math.PI / 180;
deltaZ = zFar-zNear;
sine = (float)Math.sin(radians);
if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) {
return;
}
cotangent = (float)Math.cos(radians) / sine;
matrix.m00 = cotangent / aspect;
matrix.m11 = cotangent;
matrix.m22 = -(zFar + zNear) / deltaZ;
matrix.m23 = -1;
matrix.m32 = -2 * zNear * zFar / deltaZ;
matrix.m33 = 1;
setChanged(true);
}
In Mesa, matrix.m33 = 0;. Why is there a difference here? Is this an error in Mesa, in Xith3D, or does Xith3D handle it’s matricies in a fundementally different way?