   Confused by camera angles:
  I'd been using D3DXMatrixLookAtLH to set the position of my camara, but wanted to specifiy the angle the camera is directed in rather than the point it is looking at (for now anyway).  I was getting confused by the trigonometry for working it out so I tried to work from the tutorial on toymaker:  http://www.toymaker.info/Games/html/camera.html and came up with the following:D3DXVECTOR3 up=D3DXVECTOR3(0.0f, 1.0f,0.0f);D3DXVECTOR3 look=D3DXVECTOR3(0.0f, 0.0f,1.0f);D3DXVECTOR3 right=D3DXVECTOR3(1.0f, 0.0f,0.0f);D3DXVECTOR3 position=D3DXVECTOR3(0.0f, 3.0f,-8.0f);D3DXMATRIX yawMatrix;D3DXMatrixRotationAxis(&yawMatrix, &up,cameraX);D3DXMATRIX rolMatrix;D3DXMatrixRotationAxis(&rolMatrix, &look,cameraY);D3DXMATRIX pchMatrix;D3DXMatrixRotationAxis(&pchMatrix, &right,cameraZ);D3DXVec3TransformCoord(&look,&look,&yawMatrix); D3DXVec3TransformCoord(&right,&right,&yawMatrix);D3DXVec3TransformCoord(&up,&up,&rolMatrix); D3DXVec3TransformCoord(&right,&right,&rolMatrix);D3DXVec3TransformCoord(&up,&up,&pchMatrix); D3DXVec3TransformCoord(&look,&look,&pchMatrix);D3DXMatrixIdentity(&viewMatrix);viewMatrix._11 = right.x; viewMatrix._12 = up.x; viewMatrix._13 = look.x;viewMatrix._21 = right.y; viewMatrix._22 = up.y; viewMatrix._23 = look.y;viewMatrix._31 = right.z; viewMatrix._32 = up.z; viewMatrix._33 = look.z;viewMatrix._41 = - D3DXVec3Dot(&position, &right); viewMatrix._42 = - D3DXVec3Dot(&position, &up);viewMatrix._43 = - D3DXVec3Dot(&position, &look);//viewMatrix._41 = 0.0f;//viewMatrix._42 = -3.0f;//viewMatrix._43 = 8.0f;To start with I'd been using the commented code, but I realised it was rotating the camera and then backing away that distance from the object rather than moving to the coordinates (0.0f, 3.0f,-8.0f).  So after seeing what was going on, I tried a simpler method which seemed to give me the same results:D3DXMATRIXA16idMatrix;D3DXMatrixRotationYawPitchRoll(&viewMatrix, cameraX, cameraY, cameraZ);D3DXMatrixIdentity(&idMatrix);idMatrix._41 = 0.0f;idMatrix._42 = -3.0f;idMatrix._43 = 8.0f;D3DXMatrixMultiply(&viewMatrix, &idMatrix, &viewMatrix);The cameraX, cameraY, cameraZ and viewMatrix variables are all global because I need to adjust them to move the camera around in my world.  I was also hoping to just multiply the view matrix by other matrices to rotate/translate it relative to it's current position.So, what I want to do is set the camera's position in the world and it's angle then to be able to move it forward/backward in the direction it's facing and to be able to rotate it to for example 5 degrees left of the direction it's currently facing.  I hope I've not made that too confusing.  Also, when I rotate in one direction, I get distortion and the whole world gets narrower at that angle.  I initialise the camera angles to 0.0f and use the following code to rotate the camera:case VK_NUMPAD4:cameraX = fmod(cameraX + D3DX_PI/64, D3DX_PI*2);break;case VK_NUMPAD6:cameraX = fmod(cameraX - D3DX_PI/64, D3DX_PI*2);break;case VK_NUMPAD7:cameraY = fmod(cameraY + D3DX_PI/64, D3DX_PI*2);break;case VK_NUMPAD9:cameraY = fmod(cameraY - D3DX_PI/64, D3DX_PI*2);break;case VK_NUMPAD1:cameraZ = fmod(cameraZ + D3DX_PI/64, D3DX_PI*2);break;case VK_NUMPAD3:cameraZ = fmod(cameraZ - D3DX_PI/64, D3DX_PI*2);break;EDIT:  I just thought how to explain this.  I want to rotate my camera's look-at point around the camera itself and then move the camera in the direction it's facing.[Edited by - CodeReaver on May 26, 2006 10:15:31 AM]
  The first method looks ok. The second method will give you completely different results. Specifically, the second method will give you the inverse of the first method. The reason is that first method is similar to the second except that it is also inverting the matrix -- the rotation part is transposed and the translation is negated and transformed.   