Original Post
Hello, I have the following code:
void Camera::translate(float x, float y, float z)
{
D3DXMATRIX tmp;
D3DXMatrixTranslation(&tmp, x, y, z);
camMatrix = camMatrix*tmp;
}
void Camera::rotateX(float x)
{
D3DXMATRIX tmp;
D3DXMatrixRotationX(&tmp, D3DXToRadian(x));
camMatrix = camMatrix*tmp;
}
void Camera::rotateY(float y)
{
D3DXMATRIX tmp;
D3DXMatrixRotationY(&tmp, D3DXToRadian(y));
camMatrix = camMatrix*tmp;
}
void Camera::rotateZ(float z)
{
D3DXMATRIX tmp;
D3DXMatrixRotationZ(&tmp, D3DXToRadian(z));
camMatrix = camMatrix*tmp;
}
void Camera::mouseMoved(int dx, int dy)
{
rotateY(-dx);
rotateX(-dy);
}
It seems to work great at first, when i move the mouse up and down, and left and right the camera responds correctly, Even moving the mouse diagonally gives the correct results, however when i move the mouse in a circular motion - the world itself starts rotating. I understand that this is because I need to ensure that when I rotate around the Y axis it is always (0,1,0) - but i have no idea how to do that. I thought that is what D3DXMatrixRotationY was supposed to do and D3DXMatrixRotationAxis rotates around an arbitrary axis. Any suggestions? [Edited by - FoxMulder900 on October 6, 2008 3:30:58 PM]