2020年6月3日 星期三

week15

今天的主題是:攝影機、運鏡
一樣先下載windows, data, 32.dll檔
現在要用的是projection.exe
fov: feld of view 視野
fovy: Y方向的視野
zNear: Z方向,進的面
zFar: Z方向,遠的面
  • left: 近的面邊界
  • right: 近的面邊界
  • bottom: 近的面邊界
  • top: 近的面邊界
  • near: 近的面離攝影機的距離
  • far: 遠的面離攝影機的距離

  • glOrtho()(方形)
    • 參數同 glFrustum()
  • gluLookAt()(攝影機調整)
    • 前3個參數: 攝影機看的方向(眼睛)
    • 中3個參數: 畫面中心點位置(C位,Center)
    • 後3個參數: 攝影機旋轉角度
➽實作:改寫範例程式
    • ctrl+F 搜尋 resize
    • 將 glFrustum() 改成  gluPerspective()

    切邊框:改原函式glFrustum變成gluPerspective


    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);
        gluPerspective( 60, 1, 0.001,1000); 

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity() ;
    }

    縮放視線


    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);
        ///gluPerspective( 60, 1, 0.001,1000);
        glOrtho(-2.4, +2.4, -1.2, +1.2, -6.0 ,+6.0);    (太大了)

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity() ;



    ***適當調整***
        glOrtho(-3.4, +3.4, -2.2, +2.2, -6.0 ,+6.0);   

    沒有留言:

    張貼留言