1
這是結果的樣子: 投影矩陣似乎是錯誤
並採用正交矩陣相同的結果:爲什麼使用投影矩陣,使一切看起來怪異
任何想法?
我的觀點:
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);
}
你應該做一些基本的調試。通過您的代碼運行一些測試座標。 – 2014-12-07 11:06:59
@Oliver我使用Vector3對它進行了測試,並比較了透視和正交。只有Z軸是不同的(透視的Z比正交的Z大1)。那麼Z軸有什麼問題? – PuRe 2014-12-08 19:22:29