Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: suggestions on implementing a viewing system

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Location
    linkoping
    Posts
    1

    suggestions on implementing a viewing system

    Hey

    So I got a simple viewing system where I can change pitch and yaw. I store these as euler angles xrot and yrot and apply them using glRotate. Now I want to add roll.

    First I thought I'll just add a third rotation variable(zrot) and that works good if I only have simple keyboard input. But with mouse input it gets trickier. If roll=0, mouse y movement effects pitch and x movement effects yaw. But when roll!=0 this doesn't work.

    So then I thought I'll just define the viewing through dir/up/right vectors and rotate around them. This almost works. The problem is that by storing the vectors as floats and continuisly updating them the coordinate system gets misaligned. I read some recommendations about resetting the coordinate system byt recalculating the right/up vectors by using a predefined up vector like (0,1,0). This doesn't work great either since my original up vector might not always be 'up'. There must be an easier way.

    Any help or recommendations greatly appreciated. If at all possible I like to keep using euler angles/math.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Oct 2002
    Location
    San Diego, CA, USA
    Posts
    211

    Re: suggestions on implementing a viewing system

    Sorry, to survive that, I went to a library of matrix math functions. Now almost all my math is done on CPU. I just make sure it's optimized, that's all.

  3. #3
    Intern Contributor
    Join Date
    Oct 2003
    Posts
    68

    Re: suggestions on implementing a viewing system

    one way to fix the front/up/right vectors would be something like
    Code :
    right = front x up
    up = right x front
    where x is cross product, and where i might have the right hand side of either or both of those backwards

    alternately, you can use quaternions to store the rotation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •