GetProjectionMatrix vs _make/convertProjectionMatrix

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
Maestro81
Gnoblar
Posts: 23
Joined: Wed Jul 02, 2008 7:30 pm
x 3

GetProjectionMatrix vs _make/convertProjectionMatrix

Post by Maestro81 »

I was wondering, in order to get a proper understanding of Ogre's projection matrix, why the following two code snippets do not return the same projection matrix:

Code: Select all

Ogre::Matrix4 pm1 = m_camera->getProjectionMatrix();
Returns
Matrix4( row0{4.38262 0 0 0 } row1{0 2.41421 0 0 } row2{0 0 -1.0001 -10.0005 } row3{0 0 -1 0 })

Code: Select all

Ogre::Matrix4 temp, pm2; 
Ogre::Root::getSingleton().getRenderSystem()->_makeProjectionMatrix(m_camera->getFOVy(), m_camera->getAspectRatio(), m_camera->getNearClipDistance(), m_camera->getFarClipDistance(), temp);
Ogre::Root::getSingleton().getRenderSystem()->_convertProjectionMatrix( temp, pm2 );
Returns
Matrix4( row0{4.38262 0 -0 0 } row1{0 2.41421 -0 0 } row2{0 0 -1.00003 -2.50012 } row3{0 0 -1 0 })

So, element [2, 3] differs.. From my understanding, this is dependent on the far/near planes... (I'm using the Direct3D RenderSystem)

Anyone any idea why these retrieving the projection matrix does not provide the same result as making a projection matrix with the current camera properties?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5299
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: GetProjectionMatrix vs _make/convertProjectionMatrix

Post by dark_sylinc »

GetProjectionMatrix returns a right hand proj matrix with depth in the range [-1; 1]

_makeProjectionMatrix creates an API-specific proj matrix.
convertProjectionMatrix takes an Ogre proj matrix and converts it to an API matrix.

So convertProjectionMatrix( camera->GetProjectionMatrix() ) should return the same as _makeProjectionMatrix.

Though I wouldn't rely on _makeProjectionMatrix. It seems to be dead code (aka not used anywhere in Ogre).
Maestro81
Gnoblar
Posts: 23
Joined: Wed Jul 02, 2008 7:30 pm
x 3

Re: GetProjectionMatrix vs _make/convertProjectionMatrix

Post by Maestro81 »

dark_sylinc wrote:GetProjectionMatrix returns a right hand proj matrix with depth in the range [-1; 1]

_makeProjectionMatrix creates an API-specific proj matrix.
convertProjectionMatrix takes an Ogre proj matrix and converts it to an API matrix.

So convertProjectionMatrix( camera->GetProjectionMatrix() ) should return the same as _makeProjectionMatrix.

Though I wouldn't rely on _makeProjectionMatrix. It seems to be dead code (aka not used anywhere in Ogre).
Tnx
Post Reply