(1)旋轉 移動
(2)mouse 旋轉
(3)階層式旋轉
(4)階層式移動
網址:jsyeh.org/3dcg10
課堂作業1-2


我覺得1-2 這個比較像是車子在自己轉
課堂作業1-3
比較像場景

上課的茶壺(左右)
#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT); //背景顏色
glPushMatrix(); //備份Matrix (Rotate/Translate/Scale等資料)
glRotatef(rotX,0,1,0);
glColor3f(1,0,0);
glutSolidTeapot(0.3);
glPopMatrix(); //還原Matrix (Push前的資料形式)
glutSwapBuffers(); //把上面準備好的程式一次全展現出來
}
void motion(int x,int y) //旋轉的函式
{
rotX=x;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH); //兩倍記憶體和深度用於3D
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}

上課的茶壺(上下)
旋轉杯
Q1:什麼是 (1)glPushMatrix(); Ans:將程式碼丟出來進行處理
(2)glPopMatrix(); Ans:將程式碼丟回來使用
Q2:什麼是 (1)Buffers? Ans:建立緩衝區,讓程式碼先跑一遍
(2)Double? Ans:跑兩次緩衝
沒有留言:
張貼留言