public void SetCustomParameter(int index, Axiom.MathLib.Vector4 val) { throw new NotImplementedException(); }
public override void ApplyObliqueDepthProjection(ref Axiom.MathLib.Matrix4 projMatrix, Axiom.MathLib.Plane plane, bool forGpuProgram) { // Thanks to Eric Lenyel for posting this calculation at www.terathon.com // Calculate the clip-space corner point opposite the clipping plane // as (sgn(clipPlane.x), sgn(clipPlane.y), 1, 1) and // transform it into camera space by multiplying it // by the inverse of the projection matrix /* generalised version Vector4 q = matrix.inverse() * Vector4(Math::Sign(plane.normal.x), Math::Sign(plane.normal.y), 1.0f, 1.0f); */ Axiom.MathLib.Vector4 q = new Axiom.MathLib.Vector4(); q.x = Math.Sign(plane.Normal.x) / projMatrix.m00; q.y = Math.Sign(plane.Normal.y) / projMatrix.m11; q.z = 1.0f; // flip the next bit from Lengyel since we're right-handed if (forGpuProgram) { q.w = (1.0f - projMatrix.m22) / projMatrix.m23; } else { q.w = (1.0f + projMatrix.m22) / projMatrix.m23; } // Calculate the scaled plane vector Axiom.MathLib.Vector4 clipPlane4d = new Axiom.MathLib.Vector4(plane.Normal.x, plane.Normal.y, plane.Normal.z, plane.D); Axiom.MathLib.Vector4 c = clipPlane4d * (1.0f / (clipPlane4d.Dot(q))); // Replace the third row of the projection matrix projMatrix.m20 = c.x; projMatrix.m21 = c.y; // flip the next bit from Lengyel since we're right-handed if (forGpuProgram) { projMatrix.m22 = c.z; } else { projMatrix.m22 = -c.z; } projMatrix.m23 = c.w; }