Jump to content
  • Advertisement

Archived

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

doctorsixstring

Camera Movement

This topic is 5587 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

I have a camera at a given position (vCameraTranslation) with a yaw/pitch/roll stored in the variable ''vCameraRotation''. I am using quaternions to set the camera''s facing. My problem is that I want to be able to move the camera forward/backward/side-to-side based on its current yaw/pitch. So basically I need to calculate the 3D vector described by the yaw/pitch angles. Any thoughts/solutions? -Mike

Share this post


Link to post
Share on other sites
Advertisement
I figured it out. In case any one else was wondering, here''s how I did it:

void MoveCam(float x, float y, float z)
{
//build a matrix from the camera''s yaw/pitch/roll (''m_vCameraRot'')
D3DXMATRIX matCam;
D3DXMatrixRotationYawPitchRoll( &matCam, m_vCameraRot.x, m_vCameraRot.y, m_vCameraRot.z);

//rotate the movement vector by the rotation matrix
D3DXVECTOR3 vMove(x, y, z);
D3DXVec3TransformCoord(&vMove, &vMove, &matCam);

//move the camera
m_vCameraTrans += vMove;
}

Then apply ''m_vCameraTrans'' and ''m_vCameraRot'' to the view matrix and your all set.

-Mike

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!