3D相交测试

发布于 2024-08-20 14:02:08 字数 110 浏览 3 评论 0原文

我加载了这个3D模型。然后在同一个屏幕上,我在上面画了很多点。我如何确定这些点是否在模型上。仅考虑XY平面。

任何人都可以教我如何仅在 XY 平面上进行 3D 相交测试,因为我真的一无所知。

I have this 3D model loaded.Then on the same screen, I have many points draw on it.. how Can I determine whether the points are on the model or not.Only take the XY plane for consideration.

Anyone can teach me how to do a 3D intersection test only on the XY plane, because Im really clueless.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妄断弥空 2024-08-27 14:02:08

有几种方法可以做到这一点。最实用的选项可能是:

a) 使用渲染模型时写入的模板缓冲区,并使用 glReadPixels(...) 来查看是否为屏幕上的特定 (x,y) 点设置了模板缓冲区。

b) 将 (x,y) 点从相机位置转换为 3D 空间中的一条线。然后用您的模型进行线相交测试(简单但缓慢的方法是针对每个多边形进行测试,您可以通过使用边界体积等清楚地获得更快的结果)

c)使用 glReadPixels(...) 读取屏幕上的 (x,y) 点。显然,只有当您能够准确地区分哪些颜色属于模型的一部分时,这才有效。

如果您能够为此目的设置并使用模板缓冲区,那么 a) 可能是最容易实现的。否则 b) 可能是最有用的通用解决方案。

There are several ways you could do this. Most practical options are probably:

a) Use a stencil buffer that you write to when you render your model and glReadPixels(...) to see if the stencil buffer is set for the particular (x,y) point on the screen.

b) Convert the (x,y) point into a line in 3D space from the camera position. Then do a line intersection test with your model (the simple but slow way would be to test against each polygon, you can clearly get faster results by using bounding volumes etc.)

c) Use glReadPixels(...) to read the colour of the (x,y) point on the screen. Obviously this will will only work if you are able to accurately distinguish which colours are part of the model or not.

If you are able to set up and use a stencil buffer for this purpose, then a) is probably the simplest to implement. Otherwise b) is probably the most useful general solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文