• ### Popular Now

• 10
• 9
• 13
• 10
• 18

#### Archived

This topic is now archived and is closed to further replies.

# Projection & View Matrix Questions

This topic is 5412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

First off this may sound like newbie questions but I have to ask. I am making a 3D editor and in my 3 ortho views I was orignally doing the calculations for laying out cubes with plain old code. This works fine until I want to start doing special things like rotation and what not. Thus, matrix calculations come into play. I understand how to do the calculations for transforming ''model'' coordinates into world coordinates and what not. My problem comes from not using DirectX in the ortho views. I''m using straight GDI there. So now to the questions: If I compute the projection and the view matrices and then multiply them together, my vector is not translated properly. Do I have to do the projection matix * vector and then use the result * view matrix? Or am I just not doing my calculations properly?

D3DXMatrixOrthoLH(&m_mtxProjection,
m_fWidth,
m_fHeight,
m_fNearPlane,
m_fFarPlane);

D3DXMatrixLookAtLH(&m_mtxView,
&m_vCurrent,
&m_vLookAt,
&m_vUp);

// m_mtxCombined is m_mtxView * m_mtxProjection

D3DXVECTOR4 vRet;
D3DXVec3Transform(&vRet,
&D3DXVECTOR3(*vWorld),
&m_mtxCombined);


##### Share on other sites
Remember that you need to apply to a vector the world matrix, then the view matrix, then the projection matrix.

This is equivalent to V'' = Proj * View * Mod * V, since matrix muliplication operates from right to left (just like functions).

Use m_mtxCombined = m_mtxProjection * m_mtxView instead!

ToohrVyk