(1)期中考模擬考
glPushMatrix();備份矩陣
glTranslatef(x,y,z);移動
glRotatef(angle,x,y,z);旋轉
glScalef(x,y,z);縮放
glBegin(GL_POLYGON);///開始畫
glColor3f(r,g,b);///顏色
glNormal3f(nx,ny,nz);///法向量
glTexCoord2f(tx,ty);///貼圖座標
glVertex3f(x,y,z);///頂點
glEnd();///結束畫
glPopMatrix();///還原矩陣
(2)T-R-T轉動
(3)打光
照著之前的步驟:
1.首先下載freeglut
2.開啟glutproject
3.更改路徑到freeglut
4.run and bluit
5.打出
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPopMatrix();
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
6.找尋light
宣告光源及打光的調整: glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, high_shinines
7.把light以上的程式碼都刪掉
8.run and bluit
9更改程式碼
const GLfloat light_position[] = { 2.0f, -5.0f, 0.0f, 0.0f };
10.float angle=0;
angle++;
宣告angle來跑出angle程式碼
11.旋轉程式碼:
glutIdleFunc(display);
(1) glutSolidTeapot(大小);
glutSolidCube(大小)->正方體
glutSolidCone(底r,高h,slice,stack);->角錐
柳丁切 堆疊
glutSclaef(0.5,0.5,0.5);
glutSolidDodecahedron();->烏龜殼
glutSolidIcosahedron();->8角體
(4)機器人
沒有留言:
張貼留言