长时间监听,第一次来电。 所以我一直在玩Android NDK,并且我正处在一个我不想要点击世界坐标的点,但是我无法让它工作。 问题是近点和远点的x和y值是相同的,这对于透视投影来说似乎并不正确。场景中的所有绘制行,所以我有点困惑,为什么它不会正确unproject,反正这里是我的代码请帮助谢谢Unprojecting屏幕坐标在OpenGL ES 2.0中的世界
//x and y are the normalized screen coords
ndk_helper::Vec4 nearPoint = ndk_helper::Vec4(x, y, 1.f, 1.f);
ndk_helper::Vec4 farPoint = ndk_helper::Vec4(x, y, 1000.f, 1.f);
ndk_helper::Mat4 inverseProjView = this->matProjection * this->matView;
inverseProjView = inverseProjView.Inverse();
nearPoint = inverseProjView * nearPoint;
farPoint = inverseProjView * farPoint;
nearPoint = nearPoint *(1/nearPoint.w_);
farPoint = farPoint *(1/farPoint.w_);
非常感谢Reto,我停止使用ndk_helper矢量数学的东西,它给了我更多可信的结果。作为谷歌官方NDK的一部分,它甚至没有让我意识到这是错误的。 欢呼声 – BlondesDoingMath 2014-10-09 09:59:26