如何定义 glutWireCube 的起始位置?

How can I define starting position of glutWireCube?

我对编程还比较陌生,所以我可能不会使用正确的术语。我正在尝试只用 glutwirecubes 创造一只狗,但是我不知道如何定义后腿的起始位置,也不知道如何关闭 'shoulder' 和 'shoulder' 之间的 space 'elbows'。我将每个 body 部分指定为通过按键旋转。我也意识到我对 glPushMatrix 和 glPopMatrix 的使用可能不正确,因为我不完全理解矩阵堆栈是如何 saved/loaded.

    glPushMatrix();
glTranslatef(-1, 0, 0);
glRotatef((GLfloat)body,1, 0, 0);//sets rotations about x,y,z axis
glTranslatef(1, 0, 0);
glPushMatrix();
glScalef(2.0, 0.4, 0.5);//sets dimensions of cube
glutWireCube(2.0);//sets scale of wire cube
glPopMatrix();

glPopMatrix();

glPushMatrix();
glTranslatef(-1, 0, 0);
glRotatef((GLfloat)shoulder, 0, 0, 1);//sets rotations about x,y,z axis
glTranslatef(1, 0, 0);
glPushMatrix();
glScalef(1.5, 0.4, 0.5);//sets dimensions of cube
glutWireCube(.75);//sets scale of wire cube
glPopMatrix();

glTranslatef(1,0,0);
glRotatef((GLfloat)elbow,0,0,1);//sets rotations about x,y,z axis
glTranslatef(1,0,0);
glPushMatrix();
glScalef(1.5,0.4,0.5);//sets dimensions of cube
glutWireCube(.75);//sets scale of wire cube
glPopMatrix();

glPopMatrix();
glutSwapBuffers();

图片是我的目标位置,但是我的立方体一开始总是水平的。

之前用glTranslate,至于它的朋友!

例如,您可能会进行平移,使中心现在位于拐角处,这样您的旋转就会围绕这个新手柄旋转。