简体   繁体   English

从任意角度进行3D拾取

[英]3d picking from arbitrary viewpoint

I created a 3d scene of many pipes (valves,manhole) of different colors and materials . 我创建了一个3d场景,其中包含许多不同颜色和材料的管道(阀门,人孔)。 Now I want to use the mouse to pick them and get their attributes(color,material). 现在,我想使用鼠标来选择它们并获取它们的属性(颜色,材料)。 I've tried to use glupushmatrix, the method provided by OpenGL API ,it worked when the viewpoint is almost right in front of the pipe.But when looking from different viewpoints ,such as from (0,1,1) to (0,0,0),it can't do it. 我尝试使用OpenGL API提供的方法glupushmatrix,它在视点几乎位于管道正前方时有效。但是,从不同的视点(例如,从(0,1,1)到(0, 0,0),则无法执行。 What's more , I didn't find any projection settings for functions glulookat before glupushmatrix . 而且,在glupushmatrix之前,我没有找到glulookat函数的任何投影设置。 I also tried to use ray tracing based picking using math , but I found it is difficult to do intersection testing for each pipe using brute force . 我还尝试通过数学使用基于光线跟踪的拾取,但是我发现使用蛮力很难对每个管道进行相交测试。

OpenGL provide a special render mode ( GL_SELECT ) to help achieving picking. OpenGL提供了一种特殊的渲染模式( GL_SELECT )以帮助实现拾取。

To implement it you have to: 要实现它,您必须:

  • Name your selectable primitives 命名您的可选原语
  • Add a rendering pass with GL_SELECT mode. 使用GL_SELECT模式添加渲染通道。

edited the link: 编辑了链接:

Follow this tutorial... 遵循本教程...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM