2011-09-13 40 views
0

我正在寫一個簡單的陀螺測試應用程序,我希望能夠通過將手機傾斜到不同的方向來實現多邊形的不同側面。它與頭部跟蹤渲染技術類似,但我假設眼睛位置固定,只有手機相對於眼睛(相機)移動。在左/右方向傾斜的平截頭體的Android opengl問題

爲此,我在opengl es中使用了傾斜的平截頭體技巧。我可以毫無問題地抵消頂部/底部/近/遠方向的平截頭體。如果我將偏移值除以2,則只有左/右方向起作用時纔會出現真正奇怪的部分。有效地將「平截頭體」從真正應該是「縮小」的。

這裏是工作示例代碼與除以2的錯誤在左/右方向:

// xEyePhone is the transform of eye relative to the screen, note the /2.0f for the 3rd and 4th params. 
Matrix.frustumM(_ProjMatrix, 0, -ratio-xEyePhone[12]/2.0f, ratio-xEyePhone[12]/2.0f, 1-xEyePhone[13], 1-xEyePhone[13], xEyePhone[14], xEyePhone[14]+10); 

Matrix.setLookAtM(_VMatrix, 0, xEyePhone[12], xEyePhone[13], xEyePhone[14], 
XEyeCenterWorld[12], xEyeCenterWorld[13], xEyeCenterWorld[14], 
XUpVectorWorld[12], xUpVectorWorld[13], xUpVectorWorld[14]); 

任何人碰到這個來了?

+0

可能與http://stackoverflow.com/questions/11697728/why-does-the-matrix-generated-by-androids-frustumm-differ-from-the-redbooks –

回答

0

您將投影查看矩陣應用於投影。你不應該這樣做。投影變換僅設置「虛擬透鏡」的屬性。放置相機發生在模型視圖轉換中。

在執行照明時不保留這兩個單獨的原因問題。

+0

https://code.google .com/p/android/issues/detail?id = 35646不,這是框架中的一個錯誤。 – PawelP