2024年6月7日 星期五

盛week16

 

期末報告還沒做涼涼上圖學

Week16-camera

01開啟小葉的教材,了解GLLook at 中 eye , center , up 三個函數中XYZ三個軸的意思

 
*Codeblock前置設定(openCV ,compiler.....)

16-1建立新project:(16-1_sample)和(16-1_glLookAt)*原圖

使用glLookAt函式把中心點變為左上的紅色圓球

- gluLookAt(0,0,0(Eye),  -2.4,1.2,-6,(Center)  0,1,0(Up));

*呈現如圖

增加Keyboard if函數可以按一個鍵盤切換想要的視角

EX.

if(key=='1'){

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt(0,0,0, -2.4,1.2,-6, 0,1,0);

結果:

Press ' 0 '

Press ' 1 '

Press ' 2 '


16-2 (Teapot_LookAt)

*會使用到下列個函數

1.gluOrtho(左,下,上,近,遠)

2.gluperspect(張角,長寬比,近,遠)

3.gluFrustum(左,右,下,上,近,遠)

建立專案 貼上11行GLUT函式

新增reshape函式

void reshape(int w,int h){

    float ar = w /(float)h;

    glViewport(0,0,w,h);

    glMatrixMode(GL_PROJECTION);

    glLoadIdentity();

    gluPerspective(60,ar,0.1,100);

    glMatrixMode(GL_MODELVIEW);

    glLoadIdentity();

    gluLookAt(0,0,-3,0,0,0,0,1,0);

}

在main函式加上

glutReshapeFunc(reshape);

*呈現出的無頁面比例都不會改變


16-3多個圖



沒有留言:

張貼留言