PDA

View Full Version : individual segment



opengluser
10-26-2002, 09:02 PM
hi, how can i make the segment rotate individually, if my segment code is as below:

....
// *finger segment 2* //
glTranslatef(0.15, -0.01, 0.0);
glRotatef ((GLfloat) f2, 0.5, 0.0, 0.25);
glTranslatef (0.25, 0.0, 0.0);
glPushMatrix ();
glScalef (1.0, 0.2, 0.5);
glutWireCube (0.5);
glPopMatrix ();

// *fing_tumb* //
glTranslatef(-0.65, -0.45, 0.0);
glRotatef ((GLfloat) ft, 0.5, 0.0, 0.5);
glTranslatef (0.25, 0.0, 0.0);
glPushMatrix ();
glScalef (1.0, 0.15, 0.5);
glutWireCube(0.5);
glPopMatrix ();

....
======
well, my rotation is :

...
case '1':
f2 = (f2 - 90) % 180;
glutPostRedisplay ();
break;
....

thanks.

Leyder Dylan
10-27-2002, 02:32 AM
You forgot 2 "glPushMatrix()".


glPushMatrix();
// Your stuff
glPopMatrix();

glPushMatrix();
// Your stuff
glPopMatrix();

Leyder Dylan
10-27-2002, 02:33 AM
You need to put you "glTranslatef" inside the "glPush & glPop Matrix".

....
// *finger segment 2* //
glPushMatrix ();
glTranslatef(0.15, -0.01, 0.0);
glRotatef ((GLfloat) f2, 0.5, 0.0, 0.25);
glTranslatef (0.25, 0.0, 0.0);
glScalef (1.0, 0.2, 0.5);
glutWireCube (0.5);
glPopMatrix ();

// *fing_tumb* //
glPushMatrix ();
glTranslatef(-0.65, -0.45, 0.0);
glRotatef ((GLfloat) ft, 0.5, 0.0, 0.5);
glTranslatef (0.25, 0.0, 0.0);
glScalef (1.0, 0.15, 0.5);
glutWireCube(0.5);
glPopMatrix ();