Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Camera rotation from vector

  1. #1
    Intern Contributor
    Join Date
    Mar 2012

    Camera rotation from vector

    To start off, i am NOT talking about gluLookAt() to specify the camera rotation,
    so dont suggest i use it. I'm using glRotatef to alter
    camera rotation.

    So far i'v been using angle xrot,yrot,zrot (in degrees)
    to specify the camera rotation.
    Code :
    problem, say i have a unit vector (0.3433, 0.4243, 0.242) and i want to find the
    appropriate xrot,yrot,zrot to get the camera rotation according the given

    I was thinking to solve, say the xrot, i could take do
    ->angleBetween( (0.3433,0,0), (1,0,0) ) would give the xrot, and so on for
    the yrot,zrot.

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    So let me make sure I understand this correctly. You ditched gluLookAt for specifying your camera in favor of Euler angles. And now you want to use Euler angles to basically do the exact same thing that gluLookAt could do far easier.

    Why are you making everything so difficult for yourself? Use the right tool for the right job. And Euler angles are almost never the right job for anything.

    Basically, the best way to answer your question is to look at the implementation of gluLookAt and do what it does.

  3. #3
    Intern Contributor
    Join Date
    Mar 2012
    But bare with me here,

    Given an up-vector of always (0,1,0) and a nonzero direction vector (x,y,z), how do i get the rotation angles for the camera to point in the direction of the given vector?

Posting Permissions

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