Results 1 to 4 of 4

Thread: Rolling using gluLookAt().

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Ireland
    Posts
    19

    Rolling using gluLookAt().

    Hi all,

    Does anyone know of a way to make the camera roll using gluLookAt. Is there some way of doing it with the last three parameters? The reason I ask is because I need to replicate an aeroplane rolling, ie. turning left and right.

    Cheers

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Rolling using gluLookAt().

    Have not tried it out, but the code should look something like this:

    need to have the view change over time and space movied.

    int start_roll_angle = 0;
    int end_roll_angle = 360;
    int roll_angle;


    x3 = cos(roll_angle); // note need to convert degrees to randians for cos/sin function
    y3 = sin(roll_angle);
    glLookAt(x1,y1,z1, x2,y2,z2, x3,y3,0.0)
    roll_angle += rate_of_roll; //
    if (roll_angle > end_roll_angle) roll_angle = start_roll_angle; // reset if greater then 360

    Of course you will need to a routine to update your display and move your object through your world. And add something to control if to roll right or left.


    Originally posted by TolTol:
    Hi all,

    Does anyone know of a way to make the camera roll using gluLookAt. Is there some way of doing it with the last three parameters? The reason I ask is because I need to replicate an aeroplane rolling, ie. turning left and right.

    Cheers

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2002
    Location
    Ireland
    Posts
    19

    Re: Rolling using gluLookAt().

    nexusone, it doesn't work when the axis going from the planes nose to its tail is Parallel to the X axis, otherwise it works fine, thanks.
    I take it that it doesn't work because the code is not changing the z coordinate, ie, the last parameter in gluLookAt().

    Any ideas on how to rectify this problem would be appreciated.

  4. #4
    Member Contributor
    Join Date
    Dec 2001
    Posts
    91

    Re: Rolling using gluLookAt().

    I am not very strong in math "yet" but I think this has something to do with using normal rotate functions and losing your point of reference.

    The term that I have heard over and over is gimbal lock. Try searching google for "gimbal lock" and you will come up with lots of articles on what it means and ways to work around it.

    Be aware that the general solution seems to be by using matrix math.

    Good luck,
    jpummill

Similar Threads

  1. Rolling a sphere
    By Ikhan in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-12-2011, 06:18 AM
  2. Rolling ball
    By kostyabkg in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-27-2006, 07:50 AM
  3. Rolling
    By rshadarack in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-11-2004, 07:02 AM
  4. Rolling
    By rshadarack in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-10-2004, 08:42 AM
  5. Rolling Sphere
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-14-2001, 05:59 AM

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