【问题标题】:How can I define starting position of glutWireCube?如何定义 glutWireCube 的起始位置?
【发布时间】: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();

图片是我瞄准的位置,但是我的立方体总是水平方向。

【问题讨论】:

    标签: c++ graphics glut


    【解决方案1】:

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

    例如,您可以平移,使中心现在位于拐角处,以便您的旋转围绕这个新手柄旋转。

    【讨论】:

      猜你喜欢
      • 2017-09-13
      • 1970-01-01
      • 2019-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-24
      • 1970-01-01
      相关资源
      最近更新 更多