http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=69746
http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=68563
... The projection matrix creation in Irrlicht is buggy. Even given the suggested fixes in the other threads, it's still not accurate, and falls appart if you try to do anything clever, like dynamic view frustum re-sizing when the user changes your window size, for example.
If you'd like a more robust implementation, using the standard perspective projection matrix formula, try this:
Code: Select all
//! Builds a left-handed perspective projection matrix based on a field of view
inline void matrix4::buildProjectionMatrixPerspectiveFovLH(f32 fieldOfViewRadians, f32 aspectRatio, f32 zNear, f32 zFar)
{
f32 th = (f32) tan( fieldOfViewRadians / 2.0f );
f32 tw = th * aspectRatio;
f32 d = zFar - zNear;
(*this)(0,0) = 1.0f / tw;
(*this)(1,0) = 0;
(*this)(2,0) = 0;
(*this)(3,0) = 0;
(*this)(0,1) = 0;
(*this)(1,1) = 1.0f / th;
(*this)(2,1) = 0;
(*this)(3,1) = 0;
(*this)(0,2) = 0;
(*this)(1,2) = 0;
(*this)(2,2) = ( zFar + zNear ) / d;
(*this)(3,2) = 1.0f;
(*this)(0,3) = 0;
(*this)(1,3) = 0;
(*this)(2,3) = ( -2.0f * zFar * zNear ) / d;
(*this)(3,3) = 0;
}