Jump to content
  • Advertisement
Sign in to follow this  
repka3

My implementation of 3rd person camera.

This topic is 3068 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'm new in game programming and i want to post you my implementation of 3rd person camera DAOC style or WoW style and ask you something. float yAngle = gDInput->mouseDX() / 200.0f; float pitch = gDInput->mouseDY() / 200.0f; // Create Rotation matrix R with rotation around "Right Camera vector" and around Y world vector D3DXMATRIX R; D3DXMatrixRotationAxis(&R, &mRightW, pitch); D3DXMATRIX L; D3DXMatrixRotationY(&L, yAngle); D3DXVec3TransformCoord(&mRightW, &mRightW, &L); R=R*L;//sum the trasformation //keep the char in center of view by moving eye and target pos while he is moving. D3DXVECTOR3 delta_char_Wpos=charWpos-old_charPosw; m_EyePos+=delta_char_Wpos; targetWpos+=delta_char_Wpos; //trasform eye (camera) position rotating around charwpos D3DXVECTOR3 fromPointToEye=m_EyePos-charWpos; D3DXVec3TransformCoord(&fromPointToEye,&fromPointToEye,&R); //trasform target position rotating around charwpos D3DXVECTOR3 fromPointToTarget=targetWpos-charWpos; D3DXVec3TransformCoord(&fromPointToTarget,&fromPointToTarget,&R); //make eye and target relative to char world position m_EyePos=charWpos+fromPointToEye; targetWpos=charWpos+fromPointToTarget; D3DXVECTOR3 m_UpVector(0, 1, 0); D3DXMatrixLookAtLH(&mView, &m_EyePos, &targetWpos, &m_UpVector); old_charPosw=charWpos; //save char pos for finding delta pos at next loop Everything work fine but i think this is not right way cause for examples if i want to limit the max pitch of camera there is no simple way. What do you think about this implementation? Need i to find a better way? Thx all who will answer..

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!