Ogre中攝像機的一些相關函數

來源:互聯網
上載者:User


//建立攝像機

//sceneManager是一個已經存在的情境管理器執行個體的指標。

//我們在這裡構建名稱為“MainCam”的攝像機。

Camera *camera = sceneMgr->createCamera(“MainCam”);

 

//並不需要計算什麼,可以直接從視口中得到這個尺寸 這裡現實視口比例是4:3

camera->setAspectRatio(1.333333f);

 

//30度角可以讓我們看到一個長而遠的視野

camera->setFOVy(30.0f); //圖上W是這裡的角度

camera->setNearClipDistance(5.0f); //攝像機到平面xy的距離

camera->setFarClipDistance(1000.0f);//攝像機到平面x'y'的距離

 

//設定渲染模式 下面分別對應點線 點 實體渲染

camera->setPolygonMode(PM_WIREFRAME);

camera->setPolygonMode(PM_POINTS);

camera->setPolygonMode(PM_SOLOD);

PolygonMode mode = camera->getPolygonMode(); //這個不用講了

 

//攝像機的位置變換

 

//確認我們已經有一個指向“Camera”類型執行個體的指標camera。

camera->setPosition(200, 10, 200);

 

//也可以用一個三維向量來設定攝像機座標,在我們得到情境座標時候這麼做會方便一些

//camera->setPosition(Vector3(200, 10, 200));

 

//假設攝像機還在我們之前設定的200, 10, 200空間位置上。
camera->move(10, 0, 0); //攝像機移動到210, 10, 200

camera->moveRelative(0, 0, 10); //攝像機移動到210, 10, 210

 

//move ,moveRelative與 setPosition的區別

//setPosition設定攝像機的絕對座標 move和moveRelative是把攝像機移動到當前位置的相對位置上

//moveRelative與move的區別 前者是在攝像機的本地座標移動 假設攝像機像右旋轉90度 在向前移動10

//個單位,那麼本地座標是向Z方向移動10 而全局座標是像X方向移動10個單位

 

 

//指向,方向,LookAt

void setDirection(Real x, Real y, Real z);

void setDirection(const Vector3& vec);

Vector3 getDirection(void) const;

Vector3 getUp(void) const;

Vector3 getRight(void) const;

void lookAt( const Vector3& angle);

void lookAt(Real x, Real y, Real z);

void roll(const Radian& angle); //滾動繞Z軸 右手法則 旋轉 即逆時針

void roll (Real degrees){roll (Angle ( degrees ) );}

void yaw(const Radian& angle); //偏航繞Y軸

void yaw(Real degrees){yaw (Angle ( degrees ) );}

void pitch(const Radian& angle); //傾斜繞X軸

void pitch(Real degrees){yaw (Angle ( degrees ) );}

void rotate(const Vector3& axis, const Radian& angle);

void rotate(const Vector3& axis, Real degrees){

rotate(axis, Angle(degrees));}

void setFixedYawAxis (bool useFixed, const Vector3 &fixedAxis=Vector3::UNIT_Y)

//設定Y軸自由度 不能繞Y軸旋轉

const Quaternion & getOrientation (void) const

void setOrientation(const Quaternion& q);

 

//自動跟蹤

/*方法中第一個參數確定是否開啟自動跟蹤,在任何一幀渲染之前都可以重新設定它。並且需要注意在關掉自動跟蹤之前,要確保所被跟蹤的節點沒有被刪除(否則系統會拋出異常)。方法的第二個參數是被跟蹤節點得指標,除非你第一個參數是false(這時候可以用NULL),否則你必須確定調用的時候指標指向的節點必須有效。有時候你可能發現你所要跟蹤的物體太大了,以至於你都不知道“看”哪裡才好,這時候你可以設定第三個參數來定著眼點,它是一個本地空間中相對於情境節點的錨點。*/

void setAutoTracking(bool enabled,SceneNode *target=0,const Vector3 &offset=Vector3::ZERO);

 

//得到攝像機相關資訊

const Quaternion& getDerivedOrientation(void) const;

const Vector3& getDerivedPosition(void) const;

Vector3 getDerivedDirection(void) const;

Vector3 getDerivedUp(void) const;

Vector3 getDerivedRight(void) const;

const Quaternion& getRealOrientation(void) const;

const Vector3& getRealPosition(void) const;

Vector3 getRealDirection(void) const;

Vector3 getRealUp(void) const;

Vector3 getRealRight(void) const;

     /* 其中有“Real”關鍵字的方法返回的是世界空間的座標,而擁有“Derived”關鍵字的方法的傳回值是在“軸綁定”的本地座標系中(也就是說這個座標系原點是攝像機所在的點,而它的軸向和全局座標系相同)。*/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.