I'm using irr::core::CMatrix4<T>::buildProjectionMatrixOrtho().
Code: Select all
void restoreCameraOrtho(f32 width, f32 height)
{
// cameraOrtho - Restore orthogonal matrix
core::matrix4 matprj;
matprj.buildProjectionMatrixOrthoRH(
width, height,
1.0f, 3000.0f);
cameraOrtho->setProjectionMatrix(matprj, true);
}
I tried to see Irrlicht implementation, then I found some suspicious codes.
(Irrlicht : version 1.6)
Code: Select all
// Builds a right-handed orthogonal projection matrix.
template <class T>
inline CMatrix4<T>& CMatrix4<T>::buildProjectionMatrixOrthoRH(
f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar)
{
_IRR_DEBUG_BREAK_IF(widthOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(heightOfViewVolume==0.f); //divide by zero
_IRR_DEBUG_BREAK_IF(zNear==zFar); //divide by zero
M[0] = (T)(2/widthOfViewVolume);
M[1] = 0;
M[2] = 0;
M[3] = 0;
M[4] = 0;
M[5] = (T)(2/heightOfViewVolume);
M[6] = 0;
M[7] = 0;
M[8] = 0;
M[9] = 0;
M[10] = (T)(1/(zNear-zFar));
M[11] = 0;
M[12] = 0;
M[13] = 0;
M[14] = (T)(zNear/(zNear-zFar));
M[15] = -1;
#if defined ( USE_MATRIX_TEST )
definitelyIdentityMatrix=false;
#endif
return *this;
}
If this generated matrix multiply vertex, resulted vertex's "x", "y", "z" values mean always negative. because resulted vertex's "w" is negative (if input vertex's "w" is positive).
And I think it is the problem's cause.
but I don't have conviction...