Tools::Pick Class Reference

#include <pick.h>

List of all members.


Detailed Description

Pick 3D coordinates.

Pick some objects and returns the 3D coordinates from the mouse position.

pick.png

Picking the tip of the left ventricle

Uses the Z buffer to get the 3D coordinate. Renders the objects with alpha testing so transparent part of the object are not selected.

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)


Constructor & Destructor Documentation

Tools::Pick::Pick (  ) 

Tools::Pick::~Pick (  ) 


Member Function Documentation

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

Parameters:
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
Returns:
true when an object has been hit

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)

Parameters:
max picking will not occur on element with alpha<max if max is 0, everything will be picked


The documentation for this class was generated from the following file:

Generated on Tue Aug 4 17:57:43 2009 for libvd by  doxygen 1.5.5