2018年5月28日 星期一

Week14史蒂芬的課堂筆記

一、攝影機運鏡(gluLookAt()函數)
鏡頭是個立方體呈現所看到畫面是將空間內物替壓扁成現
1.垂直投影法
gluPerspective(fovy投影範圍(大小),aspect投影寬度,zNear投影前遠近,zFar後鏡遠近);
fovy:張開的角度 Field of View,in Y direction
aspect:寬長比例,設對你的畫面裡的東西才會正確
zNear :近的裁一刀
zFar:遠的裁一刀
2.透視投影法
glOrtho(左界(left),右界(rihgt),下界(bottom),上界(top),前界(near),後界(far));
left
right
bottom
top
near
far
gluLookAt(x,y,z,      鏡頭往中心點看的位置
                   x,y,z,      中心點的位置
                   x,y,z);     鏡頭旋轉

二、glutReshapeFunc()函式
保持畫面比例,加上 gluLookAt函式,可以改變視角

static void resize(int width, int height)
{
    const float ar = (float) width / (float) height;

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-ar, ar, -1.0, 1.0, 2.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity() ;
    gluLookAt(0,3,3, 0,0,0, 0,1,0);
}
 gluLookAt(0,3,3, 0,0,0, 0,1,0);
 gluLookAt(0,3,1, 0,0,0, 0,1,0);
 gluLookAt(0,2,1, 0,0,0, 0,1,0);

沒有留言:

張貼留言