Skip to main content
gamedev.net
🔒 Locked

Camera Rotation

Started by Arcus 2 replies 200+ views
Original Post
Arcus
Arcus
I am trying to get my camera to rotate and the problem I am having is that the camera rotates around the world''s origin rather than its own origin. The code I use to compute my view transform is as follows:
D3DXMATRIX mRotation, mTranslation;
D3DXMatrixRotationYawPitchRoll(&mRotation, m_fYaw, m_fPitch, m_fRoll);
D3DXMatrixTranslation(&mTranslation, m_vPosition.x, m_vPosition.y, m_vPosition.z);
m_mTransform = mRotation * mTranslation;
 
Why is it rotating around the world''s origin and not its own?
Arcus
Lestat3D
Lestat3D
When you perform a transformation using a matrix, the matrix you have is relative to the entire world coordinates, and the camera have other (polar) coordinate system. You should make a lineal transformation to modify the matrix you have turning it in camera coordinate system. You still, should learn a little about absolute coordinates and relative coordinates.
Arcus
Arcus
So, you are saying that I should keep a copy of the previous view matrix, transform it to overlay the world origin perform the rotations and traslate it back in world space? I have tried something similar and couldn''t get it to work properly. Maybe I was doing something wrong. As I understood the use of the view matrix, it is an absolute matrix in world space meaning that when it gets set, it is not being transformed relative to the last view transform. Is that correct?
Arcus

Topic Locked

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

Sign in to reply to this topic.