individual segment

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.

You forgot 2 “glPushMatrix()”.

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

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

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 ();