Skip to main content
gamedev.net
🔒 Locked

third person camera problem

Started by Luna_White Dec 14, 2008 at 1:19 AM 0 replies 550+ views
Original Post
Luna_White
Luna_White
Hello, I am trying to make a third person camera that receives a D3DXMATRIX and then follows from behind. However, I am having problems as I rotate the object around the Y Axis, the camera seems to flip in itself, as in rotating up to about 180 degrees and then instead of keep rotating, it changes the direction of rotation! Here is my code. // Vectors for the Camera's Position and Camera's Look At Target D3DXVECTOR4 CameraPos, LookAt; // Matrices to apply D3DXMATRIX matView, matCameraPos; // Set the Camera's Position scaling to 1.0f matCameraPos = OrbitCenter; matCameraPos._11 = matCameraPos._22 = matCameraPos._33 = matCameraPos._44 = 1.0f; // Apply camera's zoom and height fixing CameraPos = D3DXVECTOR4(0.0f,OrbitCenterHeight,-OrbitCurrentZoomDistance,1); // Apply Look At's height fixing LookAt = D3DXVECTOR4(0.0f,OrbitCenterHeight,0.0f,1); // Apply matrices to the camera's position and camera's target D3DXVec3Transform(&CameraPos, &(D3DXVECTOR3(CameraPos.x,CameraPos.y,CameraPos.z)), &matCameraPos); D3DXVec3Transform(&LookAt, &(D3DXVECTOR3(0.0f, 0.0f, 0.0f)), &OrbitCenter); // Create view matrix D3DXMatrixLookAtLH(&matView, &(D3DXVECTOR3(CameraPos.x, CameraPos.y, CameraPos.z)), &(D3DXVECTOR3(LookAt.x, LookAt.y, LookAt.z)), &(D3DXVECTOR3(0.0f, 1.0f, 0.0f))); // Set the Camera's matrix to the newly created view matrix for assigning later. m_matWorld = matView;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.