View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# glRotatef()

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1Nanook  Members

Posted 04 May 2009 - 10:29 PM

glRotatef(90.0, 1.0, 0.0, 0.0); glRotatef(90.0, 0.0, 0.0, 0.5); I use the above lines before I draw my object and it gets my object into the right position, but isn't it possible to do this with one line? I tried using glRotatef(90.0, 1.0, 0.0, 0.5) , but did not get the right result..

### #2Brother Bob  Moderators

Posted 04 May 2009 - 10:34 PM

Yes, any combination of rotations can be expressed as a single axis-angle rotation. What you have is Euler angles, and what you want is an axis-angle pair. So search for "euler to axis angle" or something.

### #3Nanook  Members

Posted 04 May 2009 - 11:32 PM

okay.. I'll look into that..

Just to be sure I'm on the right track here; I'm trying to build a hexagonal container.. first I draw a hexagon polygon then drawing the walls and rotating them into place.. is this the right approach? (just got the bottom and right wall for now, but wanted to be sure on the right track before I continue)
    glPushMatrix();        //bottom of the container        glColor3f(0.0,1.0,0.0);        glRotatef(90.0, 1.0, 0.0, 0.0);        glRotatef(90.0, 0.0, 0.0, 0.5);        glBegin(GL_POLYGON);            int i;            for(i = 0; i < 6; ++i)            {                glVertex2d(2*sin(i/6.0*2*PI),2*cos(i/6.0*2*PI));            }        glEnd();    glPopMatrix();    //back wall    glPushMatrix();        glColor3f(0.0,0.0,1.0);        glTranslatef(0.0, 1.0, -2.73);        glRotatef(90.0, 1.0, 0.0, 0.0);        glBegin(GL_POLYGON);            glVertex3f( 1.0, 1.0,-2.0);            glVertex3f(-1.0, 1.0,-2.0);            glVertex3f(-1.0, 1.0, 1.0);            glVertex3f( 1.0, 1.0, 1.0);        glEnd();    glPopMatrix();

### #4CTPAX  Members

Posted 05 May 2009 - 05:55 PM

You're not rotating walls... You're just setting the polygon vertex into right position... I'm not sure if you can do rotation with a single line...I know, that you can you matrix for that, but if you achieve in putting two rotations(along two different axes) into one, can it be done with three also?

### #5Brother Bob  Moderators

Posted 05 May 2009 - 09:03 PM

Quote:
 Original post by CTPAX..., but if you achieve in putting two rotations(along two different axes) into one, can it be done with three also?

As stated; any combination of rotations can be expressed as a single axis-angle rotation.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.