opengl平移,旋转顺序void display(void){glClear (GL_COLOR_BUFFER_BIT);glColor3f (1.0,1.0,1.0);glPushMatrix();glutWireSphere(1.0,20,16); /* draw sun */glRotatef ((GLfloat) year,0.0,1.0,0.0);glTranslatef (2.0,0.0,0.0);glRotatef ((GLfloat) day,0.0,1

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 15:48:18
opengl平移,旋转顺序void display(void){glClear (GL_COLOR_BUFFER_BIT);glColor3f (1.0,1.0,1.0);glPushMatrix();glutWireSphere(1.0,20,16); /* draw sun */glRotatef ((GLfloat) year,0.0,1.0,0.0);glTranslatef (2.0,0.0,0.0);glRotatef ((GLfloat) day,0.0,1

opengl平移,旋转顺序void display(void){glClear (GL_COLOR_BUFFER_BIT);glColor3f (1.0,1.0,1.0);glPushMatrix();glutWireSphere(1.0,20,16); /* draw sun */glRotatef ((GLfloat) year,0.0,1.0,0.0);glTranslatef (2.0,0.0,0.0);glRotatef ((GLfloat) day,0.0,1
opengl平移,旋转顺序
void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0,1.0,1.0);
glPushMatrix();
glutWireSphere(1.0,20,16); /* draw sun */
glRotatef ((GLfloat) year,0.0,1.0,0.0);
glTranslatef (2.0,0.0,0.0);
glRotatef ((GLfloat) day,0.0,1.0,0.0);
glutWireSphere(0.2,10,8); /* draw smaller planet */
glPopMatrix();
glutSwapBuffers();
}
行星和太阳的实例,为什么 先glRotatef ((GLfloat) year,0.0,1.0,0.0);再glTranslatef (2.0,0.0,0.0);旋转和平移的顺序如何确定?

opengl平移,旋转顺序void display(void){glClear (GL_COLOR_BUFFER_BIT);glColor3f (1.0,1.0,1.0);glPushMatrix();glutWireSphere(1.0,20,16); /* draw sun */glRotatef ((GLfloat) year,0.0,1.0,0.0);glTranslatef (2.0,0.0,0.0);glRotatef ((GLfloat) day,0.0,1
绘制物体前最靠近物体的操作是最先执行的操作,
执行顺序与代码顺序相反,
比如,
本代码中,
画出smaller planet后,
先执行Rotatef(day...),也就是自转,
再Translatef,移到圆周轨道上去,
最后Rotatef(year...).公转.