Results 1 to 4 of 4

Thread: Rotations

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2002


    Hi everyone. I am trying to rotate an object around its local axes. With the following code, I can get it to rotate around its local x axis, but it rotates around the world y and z axes.

    glTranslatef(0.0f, 0.0f, trans);
    glRotatef(rotz, 0.0f, 0.0f, 1.0f);
    glRotatef(roty, 0.0f, 1.0f, 0.0f);
    glRotatef(rotx, 1.0f, 0.0f, 0.0f);

    glBegin( GL_TRIANGLES );
    glColor4f( 1.0f, 1.0f, 1.0f, 0.5f ); glVertex3f( 0.0f, 0.0f, 0.87f );
    glVertex3f( -0.57f, 0.0f, -0.87f );
    glVertex3f( 0.57f, 0.0f, -0.87f );

    I tried to switch the order of the rotate functions, but the last one called would be the axes that was rotated around correctly. If anyone knows what I am doing wrong, or what I should do instead, please explain.


  2. #2
    Junior Member Newbie
    Join Date
    Jan 2002

    Re: Rotations

    try incrementing the angles after glEnd()->

    eg rotz+=2.0;

    this would rotate the object around at a continous 2 degree angle.

    also, try taking the 'f' out from after the points .I don't think you need it when you put the 'f' after the function name. I'm not sure about this but it works for me.

    good luck.

  3. #3
    Member Newbie
    Join Date
    Feb 2000
    Kingston, Ontario Canada

    Re: Rotations

    You may want to look at this:

    If you need more help let me know (I think that I just recently experienced your problem).

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2000

    Re: Rotations

    Hi Scott!

    If you want to rotate the object around its local axes the translate command shoud not be the first command, because it translates the object into world space. Remember that the order of the matrix operations is important (not only rotations, also translations).

    Try to but the translate command AFTER your rotations (the order of those define the dehavior too).

    Hope that helped!

    Kind regards,


    (And may the vector be with you!)

Similar Threads

  1. Rotations- help?
    By cloudy in forum OpenGL: Linux
    Replies: 4
    Last Post: 08-07-2009, 10:52 PM
  2. rotations
    By michi in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-06-2008, 05:09 AM
  3. Rotations...
    By mkardesci in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-19-2003, 01:06 PM
  4. Rotations
    By jhc in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-03-2003, 07:15 AM
  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