【问题标题】:Android opengl problem with skewed frustum in the left/right directionsAndroid opengl问题与左/右方向倾斜的截锥体
【发布时间】:2011-09-13 22:38:16
【问题描述】:

我正在编写一个简单的陀螺仪测试应用程序,我希望通过将手机倾斜到不同的方向来实现多边形的不同边。它类似于头部跟踪渲染技术,但我假设眼睛位置固定,只有手机相对于眼睛(相机)移动。

为此,我在 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]);

有人遇到过这个吗?

【问题讨论】:

标签: android opengl-es frustum


【解决方案1】:

您将观察矩阵应用于投影。你不应该这样做。投影变换只设置“虚拟镜头”的属性。放置相机发生在模型视图转换中。

在实施照明时不保持这两个独立会导致问题。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-25
相关资源
最近更新 更多