2022年3月28日 星期一

09160074 week06

講義:https://jsyeh.org/3dcg10/

●自轉VS公轉

        1.打開Transformation.exe,下方按mouse右鍵,可以切換車子的自轉、公轉
自轉

公轉

●Keyboard

glutKeyboardFunc(keyboard) 可以註冊 void keyboard(unsigned char key, int x, int y) 這個函式,再配合 stdio.h 的 printf()印出鍵盤的值





















●Keyboard_mouse_motion

剛剛的keyboard()函式, 我們再加上 mouse() 及 motion()函式





















◆做出上上週glTranslatef()移動






















◆做出縮放的程式,利用 float scale=1.0 這個變數,如果 if(mousX大於oldX)就讓 scale 放大 1%, 反過來就讓 scale 變小 1%






















◆if(key=='w' 或 key=='W') now=1做移動, if(key=='r' 或 key=='R')now=3 做縮放。接下來在 motion()裡結合if(now==1)做移動的計算, if(now==3)做縮放的計算






















◆把茶壺調整到正中心,並把視窗調大,把背景變顏色







沒有留言:

張貼留言