在OpenGL中选择构面的最简单方法是什么? [英] What's the easiest way to pick a facet in OpenGL?

查看:102
本文介绍了在OpenGL中选择构面的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找出OpenGL应用程序中鼠标光标下的哪个方面.使用选择缓冲区对我来说似乎很不准确.还有其他解决方案吗?

I want to find out which facet is under the mouse cursor in an OpenGL application. Using the selection buffer seems quite inaccurate to me. Are there other solutions?

推荐答案

使用射线相交手动进行.使用相机矩阵(如果不是明确的,则可以从OpenGL查询它),使用它在世界空间中生成拾取光线,并查看它是否与您的特定脸孔相交.在深度(t)上对交点进行排序,光标下的面最近.

Do it manually, using ray intersection. Use your camera matrix (if not explicit, you can query it from OpenGL), use it to generate a picking ray in world space, and see whether it intersects your particular face or not. Sort intersections on depth (t), and you have the closest face under the cursor.

根据您的数据结构(层次结构等)和大小,这可能会非常慢或非常有效.

Depending on your data structure (hierarchy, etc) and size this could be either really slow or really efficient.

这篇关于在OpenGL中选择构面的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆