Exemplo n.º 1
0
    public static Matrix4x4L Perspective(FloatL fov, FloatL aspect /*纵横比*/, FloatL zNear, FloatL zFar)
    {
        // 为什么这里用的是opengl的透视矩阵?

        Matrix4x4L ret    = Matrix4x4L.zero;
        FloatL     fovRad = FixPointMath.Deg2Rad * fov;

        ret.m00 = 1 / FixPointMath.Tan(fovRad * 0.5f) / aspect;
        ret.m11 = 1 / FixPointMath.Tan(fovRad * 0.5f);

        ret.m22 = -(zFar + zNear) / (zFar - zNear);
        ret.m23 = -2 * zNear * zFar / (zFar - zNear);
        ret.m32 = -1;

        return(ret);
    }