Results 1 to 2 of 2

Thread: Implementing an FPS camera and I need some help on horizontal orientation.

  1. #1
    Newbie Newbie
    Join Date
    Apr 2014

    Implementing an FPS camera and I need some help on horizontal orientation.

    I have the default view direction of (0, 0, -1), right vector of (1, 0, 0) and up vector of (0, 1, 0).

    The approach that I have taken is as follows:
    • To turn left or right, the right vector is added or subtracted to the view direction and the right vector is 'realigned' by taking the cross product of the view direction and up vector.
    • To look up or down, the up vector is used instead of the right vector.

    The problem with this approach is that when the camera looks up or down, the left and right keys do no work they way I want them to. The orientation is like a tilted disc where turning left/right distorts the horizontal orientation.

    What have I not considered?

  2. #2
    Member Contributor
    Join Date
    Jun 2012
    Most simple FPS cameras have a fixed up vector. When you turn up with your camera, the up and view direction vectors are tilted back somewhat. When you then turn right, you turn about the new up axis, not the old one, so you get a tilted disc. This could be solved by not realigning the up vector when you look up or down, but then you will no longer turn up or down with constant angular velocity.

    The approach I use for simpler cameras is to keep two Euler angles ranging from (in degrees) (0 - 90) and (0 - 360), specifying independent orientations up/down and left/right respectively. Then I use them along with the camera eye position to calculate the right and view direction vectors on the fly when I need them. Turning up/down and left/right then becomes a matter of scalar addition/subtraction on these Euler angles rather than vector products. Of course, it suffers from Gimbal lock and other things that could be solved by quaternions, but in practice for an FPS style application those aren't problems.

    A tutorial describing something similar can be found here. There are plenty others, as well.

    Also, make sure you're renormalizing everything at appropriate times.

Similar Threads

  1. COLLADA 1.5 Camera Orientation
    By recp in forum COLLADA
    Replies: 3
    Last Post: 11-06-2016, 01:01 AM
  2. Exact camera orientation using gluLookAt
    By DrthM in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 03-13-2010, 09:27 AM
  3. Camera orientation issues
    By dogdemir in forum OpenGL: General
    Replies: 0
    Last Post: 10-07-2009, 11:42 PM
  4. Camera orientation
    By Thomas in forum COLLADA
    Replies: 9
    Last Post: 10-16-2006, 02:33 PM
  5. Normal Mapping and Camera Orientation
    By golgoth13 in forum OpenGL: GLSL
    Replies: 12
    Last Post: 06-22-2006, 01:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean