private Vector3 GetCorner( FrustumPlane pp1, FrustumPlane pp2, FrustumPlane pp3 )
{
Plane p1 = _planes[ (int)pp1 ];
Plane p2 = _planes[ (int)pp1 ];
Plane p3 = _planes[ (int)pp1 ];
Matrix3 mdet;
mdet.m00 = p1.Normal.x;
mdet.m01 = p1.Normal.y;
mdet.m02 = p1.Normal.z;
mdet.m10 = p2.Normal.x;
mdet.m11 = p2.Normal.y;
mdet.m12 = p2.Normal.z;
mdet.m20 = p3.Normal.x;
mdet.m21 = p3.Normal.y;
mdet.m22 = p3.Normal.z;
float det = mdet.Determinant;
if ( det == 0 )
{
//TODO: Unsure. The C++ just returned
return Vector3.Zero; //some planes are parallel.
}
Matrix3 mx = new Matrix3(
-p1.D,
p1.Normal.y,
p1.Normal.z,
-p2.D,
p2.Normal.y,
p2.Normal.z,
-p3.D,
p3.Normal.y,
p3.Normal.z );
float xdet = mx.Determinant;
Matrix3 my = new Matrix3(
p1.Normal.x,
-p1.D,
p1.Normal.z,
p2.Normal.x,
-p2.D,
p2.Normal.z,
p3.Normal.x,
-p3.D,
p3.Normal.z );
float ydet = my.Determinant;
Matrix3 mz = new Matrix3(
p1.Normal.x,
p1.Normal.y,
-p1.D,
p2.Normal.x,
p2.Normal.y,
-p2.D,
p3.Normal.x,
p3.Normal.y,
-p3.D );
float zdet = mz.Determinant;
Vector3 r = new Vector3();
r.x = xdet / det;
r.y = ydet / det;
r.z = zdet / det;
return r;
}
}