
- Q1 : 當中心軸的位置未改變為(0,0,0),則看起來像是車子繞自己轉動
- Q2: 當改變中心軸位子,則為看起來為車子繞著改變的中心軸轉動
Homework 2
#include <GL/glut.h>
float rotX;
void display()
{
glClearColor(0.5,0,0,0.5);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX,0,1,0);
glColor3f(1,1,0);
glutSolidTeapot (0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion (int x,int y)
{
rotX= x;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Picture rotate");
glutDisplayFunc(display);
glutMotionFunc(motion);
///glutMouseFun(mouse);
glutMainLoop();
}
Homework 3
- glRotatef (rotY,1,0,0); /// 旋轉: 以X軸為選轉軸轉動,以rotx為選轉角度



沒有留言:
張貼留言