Sign in to follow this  
Corsix

D3D8 Camera

Recommended Posts

Corsix    181
I am having a little problem with the D3D8 camera. Basically, I want the camera pointing at the origin, and rotating around it when the user moves the mouse. At the moment I am using D3DXMatrixRotationX/Z and D3DXVec3TransformCoord to change the view matrix upon mouse movement:
case WM_MOUSEMOVE:
			{
				int xPos = (GET_X_LPARAM(lParam)) - 300;
				int yPos = (GET_Y_LPARAM(lParam)) - 300;
				if(abs(xPos) > 5 || abs(yPos) > 5)
				{
					D3DXMATRIX mtxRot;
					D3DXMatrixRotationZ(&mtxRot,((float)xPos)/1000.0);
					D3DXVec3TransformCoord(&m_vecCameraPosition,&m_vecCameraPosition,&mtxRot);

					D3DXMatrixRotationX(&mtxRot,((float)yPos)/1000.0);
					D3DXVec3TransformCoord(&m_vecCameraPosition,&m_vecCameraPosition,&mtxRot);

					D3DXMatrixLookAtLH(&m_matView, &m_vecCameraPosition,&m_vecCameraLookAt,&m_vecCameraUp);
				}
			}
			return 0;
However, this is not working. So, A) Can you tell why? B) Is there a better solution?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this