Results 1 to 3 of 3

Thread: My rotations is not correct.

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2001

    My rotations is not correct.

    I have tried to do some scene lately where I want to rotate my object around it self and after that translate it to an arbitrary point in space. After that I want to use gluLookAt... But when I do this I get my object to rotate around itself but then after the gluLookAt it continue to rotate but now in reference to its new point in space. How do I solve this?
    Here is my code:


    glRotatef(obj->xv, 1.0f, 0.0f, 0.0f);
    glRotatef(obj->zv, 0.0f, 1.0f, 0.0f);
    glRotatef(obj->yv, 0.0f, 0.0f, 1.0f);

    I have tried to put the gluLookAt after the rotations and the translations but then it disappears from the screen.
    What am I doing wrong?


  2. #2
    Member Newbie
    Join Date
    Oct 2000
    Toronto, Ontario, Canada

    Re: My rotations is not correct.

    If i understand correctly in order to make the object rotate about itself at an arbitrary point in space you should do this

    glRotatef(xAngle, 1.0, 0.0, 0.0);
    glRotatef(yAngle, 0.0, 1.0, 0.0);
    glRotatef(zAngle, 0.0, 0.0, 1.0);

    BTW, check your second rotate as it uses the z-angle to rotate about the y-axis.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2001

    Re: My rotations is not correct.

    One other thing to be aware of: if you perform your rotations around the x, y and z axes in order like that, you could come across everyone's favourite topic "gimbal lock". I won't go into it here - it's been covered many times already. Do a search of the discussion boards for "gimbal lock" and "quaternions" and you'll find heaps of links.


Similar Threads

  1. Replies: 0
    Last Post: 01-10-2017, 07:37 AM
  2. Rotations not correct
    By fortikur in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-28-2004, 02:58 PM
  3. Still Rotations...
    By Eric in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 09-27-2000, 02:07 AM
  4. Rotations
    By imported_Scott in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-09-2000, 12:59 PM
  5. Rotations again !
    By Eric in forum OpenGL: Advanced Coding
    Replies: 17
    Last Post: 03-02-2000, 12:21 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