【发布时间】:2015-04-16 03:56:49
【问题描述】:
我对编程比较陌生,所以我可能不会使用正确的术语。我正在尝试只用 glutwirecues 创建一只狗,但是我无法弄清楚如何定义后腿的起始位置,也无法弄清楚如何关闭我的“肩膀”和“肘部”之间的空间。我将每个身体部位分配为通过按键旋转。我也意识到我对 glPushMatrix 和 glPopMatrix 的使用可能不正确,因为我不完全了解矩阵堆栈是如何保存/加载的。
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();
图片是我瞄准的位置,但是我的立方体总是水平方向。
【问题讨论】: