XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Need Help with camera position

Last post 09/08/2009 1:06 AM by TordinBjorn. 1 replies.
  • 08/08/2009 2:22 AM

    Need Help with camera position

    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.


     

  • 09/08/2009 1:06 AM In reply to

    Re: Need Help with camera position

    of curse it dose, becus you are probebly looking 5+z or 5-z or what ever, the thing is that you must move the Z axis to so that when you wich to look straight up you should have the values like this  Lookat(whatever,+-10,pos.z)
    draw a ring with a cross inside it on a paper and it might be clear what you are doing wrong.
    Whow, thats a big memory leak...
    It sure is! and we are sinking!

    kartflygaren675@hotmail.com
Page 1 of 1 (2 items) Previous Next