当我试图围绕一个支点(腿的顶部)进行腿部运动时,反而会发生腿部开始围绕错误的点旋转,而我只想让腿来回摆动。
我该如何解决这个问题?
这是我的代码。
glPushMatrix();
glTranslatef(x+0.0f, y+6.0f, z-1.5f);
glRotatef(walk, 1.0f,0.0f,0.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.5f,0.0f); glVertex3f(x-1.0f, y-6.0f, z-3.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x-1.0f, y-6.0f, z-0.5f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x-1.0f, y-18.0f, z-0.5f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x-1.0f, y-18.0f, z-3.0f);
glTexCoord2f(0.5f,0.0f); glVertex3f(x+1.0f, y-6.0f, z-3.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x+1.0f, y-6.0f, z-0.5f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x+1.0f, y-18.0f, z-0.5f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x+1.0f, y-18.0f, z-3.0f);
glTexCoord2f(0.5f,0.0f); glVertex3f(x-1.0f, y-6.0f, z-3.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x+1.0f, y-6.0f, z-3.0f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x+1.0f, y-18.0f, z-3.0f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x-1.0f, y-18.0f, z-3.0f);
glTexCoord2f(0.5f,0.0f); glVertex3f(x-1.0f, y-6.0f, z-0.5f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x+1.0f, y-6.0f, z-0.5f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x+1.0f, y-18.0f, z-0.5f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x-1.0f, y-18.0f, z-0.5f);
glEnd();
glPopMatrix();
glPushMatrix();
glTranslatef(x+0.0f, y+6.0f, z+1.5f);
glRotatef(-walk, 0.0f,0.0f,1.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.5f,0.0f); glVertex3f(x-1.0f, y-6.0f, z+3.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x-1.0f, y-6.0f, z+0.5f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x-1.0f, y-18.0f, z+0.5f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x-1.0f, y-18.0f, z+3.0f);
glTexCoord2f(0.5f,0.0f); glVertex3f(x+1.0f, y-6.0f, z+3.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x+1.0f, y-6.0f, z+0.5f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x+1.0f, y-18.0f, z+0.5f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x+1.0f, y-18.0f, z+3.0f);
glTexCoord2f(0.5f,0.0f); glVertex3f(x-1.0f, y-6.0f, z+3.0f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x+1.0f, y-6.0f, z+3.0f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x+1.0f, y-18.0f, z+3.0f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x-1.0f, y-18.0f, z+3.0f);
glTexCoord2f(0.5f,0.0f); glVertex3f(x-1.0f, y-6.0f, z+0.5f);
glTexCoord2f(1.0f,0.0f); glVertex3f(x+1.0f, y-6.0f, z+0.5f);
glTexCoord2f(1.0f,0.5f); glVertex3f(x+1.0f, y-18.0f, z+0.5f);
glTexCoord2f(0.5f,0.5f); glVertex3f(x-1.0f, y-18.0f, z+0.5f);
glEnd();
glPopMatrix();