问题描述
我正在尝试制造一种可以随X轴移动并绕Z轴旋转的锤子武器。现在我的锤子有问题。锤子可以在固定的枢轴点上绕Z轴旋转,但是当我将锤子移动到新位置然后旋转锤子时,锤子仍然围绕旧的枢轴点旋转。
我尝试将移动的距离增加到旧的枢轴点,但是它不起作用。我该如何解决这个问题?感谢您的帮助!
这是我的代码:
glPushMatrix();
//the rotation angle of Z-axis
glTranslatef(0.5f,1.0f,-1.0f); //Back to original point
glRotatef(zr,0.0f,1.0f); //Rotating
glTranslatef(-0.5f,-1.0f,1.0f); //The rotation piovt point
//build weapon base
//the moving distant on X-axis
glPushMatrix();
glColor3f(1,0);
glTranslatef(0.5f+xr,-1.0f);
glRotatef(-90.0,1.0,0.0,0.0);
quadratic = gluNewQuadric();
gluCylinder(quadratic,0.2f,2.0f,50,50);
glPopMatrix();
//build hammer
glPushMatrix();
glTranslatef(0.0+xr,3.0f,-1.0f);
glRotatef(90.0,0.0);
glColor3f(0,1,0);
quadratic = gluNewQuadric();
gluCylinder(quadratic,50);
glPopMatrix();
glPopMatrix();
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)