2024年3月7日 星期四

真Juskii日記_Week03

 


1.從上課軟體下載freeglut




 2.將壓縮檔解壓到桌面

3.點開freeglut後復製其連結


4.點開lib後將freeglut.a復製


5.改名為libglut32.a (124KB)



6.到codeblock開新的專案 file > project,(當名為week03_mouse)




7.將上週的10行程式貼到這次的(
#include <GL/glut.h>
void display()
{
    glutSolidTeapot(0.3);
    glutSwapBuffers();

}
int main(int argc,char*argv[])
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week03_mouse");
    glutDisplayFunc(display);
    glutMainLoop();
}
)
8.改名week03 mouse , 加glutmousefunc(mouse);

9.最上面#include <stdio.h>(為了可以用printf),加void mouse含式可以操控滑鼠

10.點擊滑鼠可以在文字畫面(小黑)出現東西

11.新增可以藉由滑鼠按鈕來看座標button(第一個數字,0(左鍵),1(中鍵),2(右鍵)),state(0(按),1(放))
12.利用滑鼠來繪製一個圖的座標


13.到老師的網站(https://jsyeh.org/3dcg10/)


 14.下載data,win32


15.解壓縮data.zip,window.zip

16.將data資料夾丟到window裡面(解壓後的檔案)

17.點開Transformation.exe


18.到codeblock開新的專案 file > project,(當名為week03_mouse_glTranslanf)



19.利用剛剛的mouse程式碼加上偷幾行原本的程式碼(46,49,54),再加上一行程式碼
20.利用點擊滑鼠可以移動茶壺

21.可以根據右手來看3D的物體轉動(安培右手定則),轉動軸就是拇指,轉動方向是其他手指
對y軸轉,簡單比個讚
對x軸轉把拇指向右
對-y軸轉,就是比個倒讚
對z軸把拇指指向自己
22.到codeblock開新的專案 file > project,(當名為week03_mouse_glRotatef)


23.增加可以藉由滑鼠來選轉茶壺的程式碼





   22.到codeblock開新的專案 file > project,(當名為week03_mouse_translate_rotatef)


23.新增一些程式碼可以讓茶壺邊轉動邊移動,用w,e操控







24.上傳到github


1 則留言: