Jump to content
  • Advertisement

Archived

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

sdoherty55

Using the View Matrix

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I seem to be having some trouble getting the view matrix to work the way I want. The following example source seems to work fine:
  
	D3DXVECTOR3 vLook(0,0,1.0f);
	D3DXVECTOR3 vUp(0,1.0f,0);
	D3DXVECTOR3 vRight(1.0f,0,0);
	D3DXVECTOR3 vPos(0,0.0f,24.0f);

	D3DXMatrixIdentity(&m_matPosition);
	m_matPosition._11 = vRight.x; m_matPosition._12 = vUp.x; m_matPosition._13 = vLook.x; 
	m_matPosition._21 = vRight.y; m_matPosition._22 = vUp.y; m_matPosition._23 = vLook.y; 
	m_matPosition._31 = vRight.z; m_matPosition._32 = vUp.z; m_matPosition._33 = vLook.z; 
	m_matPosition._41 = D3DXVec3Dot(&vPos, &vRight);
	m_matPosition._42 = D3DXVec3Dot(&vPos, &vUp);
	m_matPosition._43 = D3DXVec3Dot(&vPos, &vLook);

	m_pd3dDevice->SetTransform(D3DTS_VIEW, &m_matPosition );
  
However, if I modify the position of the camera to be above the object looking down, the object is no longer in view? What am I missing?
  
	D3DXVECTOR3 vLook(0,0,1.0f);
	D3DXVECTOR3 vUp(0,1.0f,0);
	D3DXVECTOR3 vRight(1.0f,0,0);
	D3DXVECTOR3 vPos(0, 100.0f, 0.0f);  // Camera is above the object?


	D3DXMatrixIdentity(&m_matPosition);
	m_matPosition._11 = vRight.x; m_matPosition._12 = vUp.x; m_matPosition._13 = vLook.x; 
	m_matPosition._21 = vRight.y; m_matPosition._22 = vUp.y; m_matPosition._23 = vLook.y; 
	m_matPosition._31 = vRight.z; m_matPosition._32 = vUp.z; m_matPosition._33 = vLook.z; 
	m_matPosition._41 = D3DXVec3Dot(&vPos, &vRight);
	m_matPosition._42 = D3DXVec3Dot(&vPos, &vUp);
	m_matPosition._43 = D3DXVec3Dot(&vPos, &vLook);

	m_pd3dDevice->SetTransform(D3DTS_VIEW, &m_matPosition );
  

Share this post


Link to post
Share on other sites
Advertisement
Never mind, as with everthing you only figure it out after you ask for help:

  
D3DXVECTOR3 vLook(0,1.0f, 0.0f);
D3DXVECTOR3 vUp(0, 0.0f,1.0f);

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!