Step01-0 介紹Leetcode
可以練習cpe題目
Step01-1 開啟上週的Transformation.exe
到https://jsyeh.org/3dcg10/下載win32和data
把data和windows解壓縮 把data丟進解壓縮後的windows
開啟Transformation.exe
左耳靠左肩 (程式由下往上看)
Rotate轉動(角度,x,y,z)
Scale物體長寬調整(寬,高,長)
Begin開始
Step01-2 複習之前所學
Translate改x,其餘不動
調整角度時,造成車子只會在右邊旋轉
中心點不動
只調整角度時,會發現
中心點變成車子
Step02-1 自轉茶壺和公轉茶壺
使用codeblock開啟GLUT專案
並將檔名設為week05-1_T-R-T_rotate_translates
把上週的week04-1 程式複製
並將void diplay()裡的程式改成
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0);
glPushMatrix();
glTranslatef(0.8,0,0);
glRotatef(angle,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glColor3f(1,0,0);
glPushMatrix();
glRotatef(angle,0,0,1);
glTranslatef(0.8,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
angle++;
程式執行會看到自轉的綠色茶壺和把綠色茶壺當中心點的紅色茶壺
Step02-2 利用openGL_TRT認識TRT
用ToDraw畫出頭胸手
將第2個Translate移動,直到手的位置被放到第一個Translate中心點上
按下空白鍵可以看到在自轉的手
Step03-1 介紹考試內容TRT
glPushMatrix();
glTranslatef(-0.5,-0.9,0);(轉動的手肘放到正確的位置)
glRotate(-45,0,0,1);(轉動 注意正負號號轉動軸)
glTranslatef(-0.8,0.9,0);(手肘中心放到世界中心點)
drawHand();
glPopMatrix();
Step03-2 製作機器人
建立一個新GLUT專案
複製week05-1的程式
在display函式裡改成
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0,1,0);
glPushMatrix();
glutSolidCube(0.5);
glPushMatrix();
glTranslatef(0.5,0.5,0);
glColor3f(1,0,0);
glutSolidCube(0.5);
glPopMatrix();
glPopMatrix();
glutSwapBuffers();
angle++;
(1)加入glRotatef(angle,0,0,1);
(2)並把glTranslatef裡面改成(0.25,0.25,0)
(3)在glRotate上加一個Translatef(0.25,0.25,0);
沒有留言:
張貼留言