NiCamera的使用

來源:互聯網
上載者:User

1.  建立Camera.
      1)通過 NiNew NiCamera的方式獲得
      2)通過讀取NIF檔案,找到適合的Camera Node
2. 建立NiRect<float>對象, 設定Camera視口大小(假設對象為NiRect<float> kRetViewPost)
      1)全螢幕 kRetViewPost = NiRect<float>(0.0f, 1.0f, 1.0f, 0.0f);
      2)特定大小
         假設當前視窗大小800*600, 我們要在大小為200*100, 相對座標為 (cx = 300, cy = 100)的範圍內顯示Camera的內容, 那麼視口大小為:
         計算視口比例: ratioLeft = cx / 800, ratioButon = 1.0 - (cy + 100) / 600; ratioRight = (cx + 200) / 800, ratioTop =  1.0 -  cy / 600;
         kRetViewPost = NiRect<float>(ratioLeft  ratioRight , ratioTop , ratioButon );
3. 建立NiFrustum對象, 設定Camera截面體比例大小
      NiFrustum(float fLeft, float fRight, float fTop, float fBottom, float fNear, float fFar, bool bOrtho = false)
      fLeft/fRight/fTop/fButtom的值是相對於顯示地區的中心點和顯示模式而定的.
      1) 顯示模式:
            a) 正交模式 (bOrtho = true)
               假如顯示地區是200*100的大小, 那麼fLeft = -(200/2),fRight = 200/2, fTop = 100/2, fButtom = -100/2;
            b) 非正交模式 (bOrtho = false)
               不管顯示地區多大, fLeft/fButtom的值都在[-0.5, 0.0)之間,  fRight/fTop 的值都在(0.0, 0.5]之間; 如: (-0.4, 0.4, 0.46, -0.46)
            正交與非正交的區別在於, 使用非正交模式時, Camera的映像大小會受到與聚焦物體間的距離影響(即可實現縮小放大的功能), 而正交模式則不會.
      2) 顯示比例
          在正交模式下通過調用AdjustAspectRatio來設定, 而在非正交模式通過fLeft(fRight)與fButtom(fTop)的比值來設定.
      3) 裁剪距離(例如fNear = 1.0f, fFar = 1000.0f)
4. 通過NiCamera::SetViewPort(const NiRect<float>&)和Camera::SetViewFrustum(const NiFrustum& )分別設定ViewPort和Frustum

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.