# 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 on other sites
Corsix    181
Thanks =)
Got the camera movement code working when controled by the keyboard, but ouse input isnt quite working yet...