Public Group

# My implementation of 3rd person camera.

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

## 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..

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632992
• Total Posts
3009755
• ### Who's Online (See full list)

There are no registered users currently online

×