• Advertisement


This topic is now archived and is closed to further replies.

newbie question: camera rotation about origin

This topic is 5745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I am having a bit of trouble figuring out a third person camera, and I'd appreciate it if someone could post a code sample on how to rotate the camera about the origin. By this, I am confused by the matrix multiplications... so far i have this:
D3DXMATRIX matTranslate, matRotate, matTranslateBack, camera;

D3DXMatrixTranslation(&matTranslate, -camera_loc_x, -camera_loc_y, -camera_loc_z);
D3DXMatrixRotationY(&matRotate, camera_yrot);
D3DXMatrixTranslation(&matTranslateBack, camera_loc_x, camera_loc_y, camera_loc_z);

D3DXMatrixMultiply(&camera, &matTranslate, &matRotate);
//D3DXMatrixMultiply(&camera, &camera, &matTranslateBack);
g_pd3dDevice->SetTransform( D3DTS_VIEW, &camera);
but this gives rotates the camera about ITS y-axis, but not about the origin's. BTW i know you are supposed to translate, rotate, and translate back, but if I uncomment the second line, then all goes haywire. Anyway, it's late and my brain is not working as it should, so if anyone has some pseudocode/code sample on simply implementing a 3d person camera about the origin, i would so greatly appreciate it! riz [edited by - riz on May 2, 2002 3:59:52 AM] [edited by - riz on May 2, 2002 4:00:17 AM]

Share this post

Link to post
Share on other sites

  • Advertisement