#include <pick.h>
Pick some objects and returns the 3D coordinates from the mouse position.
Picking the tip of the left ventricle
Object to be picked are defined with "enable()" and "disable()"
// to define selection glPushMatrix(); glTranslate/Rotate(...); pick.enable(); // ... draw scene ... pick.disable(); glPopMatrix(); // to pick pick.get(mouse_x, mouse_y, x,y,z);
This object creates a display list between enable() and disable() The picking is done by drawing the display list in the back buffer and reading the Z buffer
Note that the GL_SELECT rendering mode is not used because it only pick primitives and can not do fragment picking. Using the Z buffer allows to detect transparent fragments.
Public Member Functions | |
| Pick () | |
| ~Pick () | |
| void | saveMatrices () |
| bool | get (int mouse_x, int mouse_y, float &x, float &y, float &z) const |
| void | enable () const |
| void | disable () const |
| void | setMaxAlpha (float max) |
| Tools::Pick::Pick | ( | ) |
| Tools::Pick::~Pick | ( | ) |
| void Tools::Pick::saveMatrices | ( | ) |
save modelview/projection matrices place this function right before drawing your object
| bool Tools::Pick::get | ( | int | mouse_x, | |
| int | mouse_y, | |||
| float & | x, | |||
| float & | y, | |||
| float & | z | |||
| ) | const |
pick objects
| mouse_x,mouse_y | (in) mouse position where (0,0) is at the lower left corner | |
| x,y,z | (out) 3D world coordinates x,y,z from mouse position |
| void Tools::Pick::enable | ( | ) | const |
start defining objects to be picked
| void Tools::Pick::disable | ( | ) | const |
stop defining objects to be picked
| void Tools::Pick::setMaxAlpha | ( | float | max | ) |
set max transparent alpha (default 0.2)
| max | picking will not occur on element with alpha<max if max is 0, everything will be picked |
1.5.5