Hello Everyone,
I need some help on my camera rotation in my program. I want to implement 2 type of rotation for my camera using trigonometry functions: an orbital type of rotation on the horizontal plane and a flight type of rotation (Pitch) on the vertical plane without switching any between cameras.
I have this code snippet using the a formula:
D3DXVECTOR3 vDxVec3 = m_Position - m_LookTarget;
m_Position.x = (float)(m_LookTarget.x + cosf(angle) * vDxVec3.x - sinf(angle) * vDxVec3.z);
m_Position.z = (float)(m_LookTarget.z + sinf(angle) * vDxVec3.x + cosf(angle) * vDxVec3.z);
The above codes works fine, it rotates the position of the camera in an orbital method.
Next code is supposed to rotate the view of the camera (Pitch):
D3DXVECTOR3 vDxVec3 = m_LookTarget - m_Position;
m_LooKTarget.y = sinf(angle);
The above code rotate's the camera view on the vertical plane but it only rotates it half, when it reaches half it bounces back. If someone could help me on this on how to make the camera pitch in a full 360 degrees using trigonometry functions I would really appreciate it.
I'm using C++ and directx9.
Thnx,
Joji Fujika.