我有这个openGL代码的问题:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix(); // put current matrix on stack
//glTranslatef(0.0f, 0.0f, 0.0f);
//glTranslatef(-4*1.5, 0.0, 4*1.5);
glRotatef(rotationAngle, 0.0f, 1.0f, 0.0f); // rotate the robot on its y-axis
glTranslatef(xpos, ypos, zpos);
DrawRobot(xpos, ypos, zpos); // draw the robot
glPopMatrix();
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能让我的机器人转过它当前所处的位置而不是原点?我认为问题出在这个片段上.
小智 13
沿z轴围绕其中心旋转对象的示例:
glPushMatrix();
glTranslatef(250,250,0.0); // 3. Translate to the object's position.
glRotatef(angle,0.0,0.0,1.0); // 2. Rotate the object.
glTranslatef(-250,-250,0.0); // 1. Translate to the origin.
// Draw the object
glPopMatrix();
Run Code Online (Sandbox Code Playgroud)
ham*_*mar 11
只需在翻译后进行旋转.订单很重要.
glTranslatef(xpos, ypos, zpos);
glRotatef(rotationAngle, 0.0f, 1.0f, 0.0f);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45628 次 |
| 最近记录: |