【发布时间】:2014-12-07 11:04:46
【问题描述】:
结果如下所示:
和使用正交矩阵的相同结果:
知道为什么使用投影矩阵会使一切看起来很奇怪吗?
我的观点:
inline static Matrix<T> ProjectionPerspectiveOffCenterLH(const T left, const T right, const T bottom, const T top, const T zNear, const T zFar)
{
return Matrix<T>(
(2.0f * zNear) / (right-left), 0.0f, 0.0f, 0.0f,
0.0f, (2.0f * zNear) / (top-bottom), 0.0f, 0.0f,
(left+right)/(left-right), (top+bottom)/(bottom-top), zFar / (zFar - zNear), 1.0f,
0.0f, 0.0f, (zNear * zFar) / (zNear - zFar), 0.0f);
}
我的正交:
inline static Matrix<T> ProjectionOrthogonalOffCenterLH(const T left, const T right, const T bottom, const T top, const T zNear, const T zFar)
{
T farNear = zFar - zNear;
return Matrix<T>(
2.0f / (right-left), 0.0f, 0.0f, 0.0f,
0.0f, 2.0f / (top-bottom), 0.0f, 0.0f,
0.0f, 0.0f, 1.0f / farNear, 0.0f,
(left + right) / (left - right), (top + bottom) / (bottom - top), -zNear / farNear, 1.0f);
}
【问题讨论】:
-
你应该做一些基本的调试。通过您的代码运行一些测试坐标。
-
@Oliver 我使用 Vector3 对其进行了测试,并比较了透视和正交。只有 Z 轴不同(透视的 Z 比正交大 1)。那么Z轴有问题吗?
标签: c++ matrix projection perspective