长期聆听者,第一次来电者。所以我一直在玩Android NDK,我正处于一个我想取消投影到世界坐标的点上,但我无法让它工作。问题是近点和远点的 x 和 y 值相同,这对于透视投影似乎不正确。场景中的一切都画得很好所以我有点困惑为什么它不能正确地取消投影,无论如何这是我的代码请帮助谢谢
//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_);