2011-05-07 62 views
5

我一直在嘗試使用gluLookAt,但我碰到過一些問題......我的第一個是什麼是相機的默認位置,每當我嘗試使用它時,我的整個場景似乎都會橫向旋轉和... 我的第二個問題是...從我已經讀了它是gluLookAt(Posx,Posy,PosZ,偏航,俯仰,滾動,然後三個向量)C++ OpenGL gluLookAt幫助

但是什麼命令是偏航俯仰和滾動假設在?

解決
相機的默認位置是在gluLookAt(0,0,0,0,0,-1,0,1,0); 感謝德魯爲您提供的所有幫助:D

回答

4

您似乎已經收到關於gluLookAt()參數的一些不良信息。從OpenGL的2.1 online documentation,參數應該如下:

eyeX, eyeY, eyeZ: 
    World coordinates of camera location 

centerX, centerY, centerZ: 
    World coordinates of camera aimpoint (what it's looking at). 
    This point will be in the center of the resulting image, assuming 
    that it lies between the near & far clip planes. 

upX, upY, upZ: 
    A vector (preferrably orthogonal to the line of sight) that specifies the 
    roll orientation of the camera (that is, which way is "up" in the image). 

正如你所看到的,有俯仰,滾轉,偏航或沒有明確提及。

另外,默認情況下,如果我記得正確的話,攝像頭位於(0,0,-1)處 - 但這並不重要,因爲您幾乎總是會將模型視圖矩陣設置爲標識來調用gluLookAt。

+0

ahhh -1 ...但是中心的含義是什麼?對不起,我真的很新的OpenGL – 2011-05-07 04:47:03

+0

@ | Phantasm |:我試圖說清楚。這是相機正在看的地方。中心 - 眼睛因此是視線矢量。 – 2011-05-07 04:52:16

+0

OpenGL中沒有攝像頭。期。在OpenGL中沒有攝像頭,沒有默認的攝像頭位置(0,0,-1)。實際發生的是,你有一個矩陣轉換世界空間中的座標,稱爲模型視圖。相機的任何運動也可以被看作是整個世界的相反運動。 gluLookAt在當前模型視圖上應用了這種相反的變換。因此,通常首先將模型視圖重置爲標識,這將在**原點**(0,0,0)處放置任何類型的相機。 – datenwolf 2011-05-07 08:22:34