Sign in to follow this  
sheeja

Directx Camera rotation

Recommended Posts

sheeja    122
I tried to rotate the camera position using the following code.Then my volume is going out of screen.How is projection and view matrix is connected.How can i set a projection matrix so that my volume never go out of screen here is my code to set view matrix and projection matrix. //Set the View Matrix D3DXMATRIXA16 matView; D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 0.0f, -3.0f ); D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); D3DXMATRIX yawpitchMatrix; D3DXMatrixRotationYawPitchRoll &yawpitchMatrix,m_stRenderingParams.m_fOrbitY,m_stRenderingParams.m_fOrbitX,0.0); D3DXVec3TransformCoord(&vUpVec ,&vUpVec , &yawpitchMatrix); vFromPt = vLookatPt + vUpVec * 1; D3DXMatrixLookAtLH( &matView, &vFromPt, &vLookatPt, &vUpVec ); m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); //Orthogonal // Set the projection matrix D3DXMATRIX matProj; FLOAT fAspect = ((FLOAT)m_d3dsdBackBuffer.Width) / m_d3dsdBackBuffer.Height; D3DXMatrixOrthoLH( &matProj,fAspect,1.0f,-5.0f, 5.0f ); m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this