简体   繁体   中英

3d picking from arbitrary viewpoint

I created a 3d scene of many pipes (valves,manhole) of different colors and materials . 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. What's more , I didn't find any projection settings for functions glulookat before glupushmatrix . 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.

To implement it you have to:

  • Name your selectable primitives
  • Add a rendering pass with GL_SELECT mode.

edited the link:

Follow this tutorial...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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