0

我正在尝试使用 GetPerspevtive 函数来检查 Perspective 函数是否返回预期的答案。

我的观点是:

Mat4<Real> Perspective(Real fovy, Real aspect, Real zNear, Real zFar)
{
        Real Cotan_fovy = (Real)1.0/Tan(fovy * (Real)0.5);

        Mat4<Real> r;
        r.SetRow(0, Cotan_fovy/aspect,  (Real)0.0,                         (Real)0.0,                                 (Real)0.0);
        r.SetRow(1,         (Real)0.0, Cotan_fovy,                         (Real)0.0,                                 (Real)0.0);
        r.SetRow(2,         (Real)0.0,  (Real)0.0,  -(zFar + zNear) / (zFar - zNear), ((Real)2.0* zFar * zNear )/ (zNear - zFar));
        r.SetRow(3,         (Real)0.0,  (Real)0.0,                        (Real)-1.0,                                 (Real)0.0);
        return r;
}

这就是我的 GetPerspective:

void GetPerspective(const Mat4<Real>& m, Real& fovy, Real& aspect, Real& zNear, Real& zFar)
{
    Real right = (Real)0.0;
    Real left = (Real)0.0;
    Real top = (Real)0.0;
    Real bottom = (Real)0.0;
    GetFrustum(m, left, right, bottom, top, zNear, zFar);

    fovy = Atan(top / zNear) - Atan(bottom / zNear);
    aspect = (right - left) / (top - bottom);
}

问题是:不管我的输入矩阵是什么,我的 GetPerspective 总是在位置 (2,3) 设置 -1

4

0 回答 0