简体   繁体   English

如何定义glutWireCube的起始位置?

[英]How can I define starting position of glutWireCube?

I am rather new to programming so I may not use the correct terminology. 我是编程的新手,所以我可能没有使用正确的术语。 I am trying to create a dog out of only glutwirecubes, however I cannot figure out how to define a starting position for the back legs, nor can I figure out how to close the space between my 'shoulder' and 'elbows'. 我正在尝试仅用臀臀肌线创建一条狗,但是我无法弄清楚如何为后腿定义起始位置,也无法弄清楚如何封闭“肩膀”和“肘部”之间的空间。 I have each body part assigned to rotate by key press. 我已将每个身体部位分配为通过按键旋转。 I also realize that my use of glPushMatrix and glPopMatrix may not be correct as I do not fully understand how the matrix stack is saved/loaded. 我也意识到我对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();

The picture is the position I am aiming for, however my cubes always start oriented horizontally. 图片是我的目标位置,但是我的立方体总是开始水平放置。

麸质样品

with glTranslate right before, as for its friends ! 与glTranslate一样,对于它的朋友们!

For instance you might translate so that the center is now at the corner, so that your rotations rotate around this new handle. 例如,您可以平移,以使中心现在位于拐角处,从而使旋转围绕此新手柄旋转。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM