Original Post
hey, im trying a 3ps style camera with directx except that all i want it to do at the moment is when i move the mouse from side to side it will rotate around a model iv been serching around the internet for something to help me with this and have become completly confusses i can get the camera to start off in the right positon but once i try and rotate around the model i start getting rotations in weird ways this is the code im using to update the camera
void initCamera(void) {
D3DXMATRIX tempMat;
D3DXMATRIX LookAtMatrix;
D3DXMATRIX ProjectionMatrix;
D3DXVECTOR3 tempVec;
D3DXMatrixLookAtLH(&LookAtMatrix,
//i use modelY - 5 so that camera is positioned behind the model
D3DXVec3TransformCoord(&tempVec, &D3DXVECTOR3(modelX, modelY - 5, 5.0f), D3DXMatrixRotationZ(&tempMat, xRoll/5000)),
&D3DXVECTOR3(modelX, modelY, 0.0f),
&D3DXVECTOR3(0.0f, 1.0f, 0.0f));
d3ddev->SetTransform(D3DTS_VIEW, &LookAtMatrix);
D3DXMatrixPerspectiveFovLH(&ProjectionMatrix, D3DXToRadian(45), (float)SCREEN_WIDTH/SCREEN_HEIGHT, 1.0f, 200.0f);
d3ddev->SetTransform(D3DTS_PROJECTION, &ProjectionMatrix);
}