Semantic Pointing for Object Picking in Complex 3D Environments
by Christian Kössler and Felix Kreuzer
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
PickingHelper Class Reference

Semantic Pointing for Object Picking in Complex 3D Environments This file is responsible the non-opengl related calculations in our implementation. More...

#include <PickingHelper.hpp>

Public Member Functions

 ~PickingHelper ()
 PickingHelper class destructor.
 
void checkNN (const GLint *pickbuffer_window, const int x_size, const int y_size, const int x_center, const int y_center, int &id, double &distance)
 Searches pickbuffer window for nearest objects and returns the nearest objects ID and its euclidean distance to the mouse cursor. More...
 
double scale_by_distance (double distance)
 Scaling function Calls either mouse_scale_linear or mouse_scale_inverse and returns the scale factor. More...
 
double springInput (double lastValue, double targetValue, double deltaTime, double springConstant)
 Uses Spring function to smooth out input. More...
 
double changeCutoffDistance (double deltaC)
 Use this method to safely change the Cutoff - distance required for the linear scaling function. More...
 
double changeMinScale (double delta_m)
 Use this method to safely change the minumum value of the scale function interval. More...
 
double changeMaxScale (double delta_M)
 Use this method to safely change the maximum value of the scale function interval. More...
 
double changeInverseExponent (double delta_S)
 Use this method to safely change the exponent of the inverse scale function. More...
 
bool toggleNaiveSearch ()
 Toggles between usage of the naive- and the sophicticated pickbuffer search algorithm. More...
 
bool toggleLinearScaling ()
 Toggles between usage of the linear- and the inverse scaling function. More...
 
bool toggleBubbleCursor ()
 Toggles wheather the bubble cursor should be displayed or the standard cursor. More...
 
void togglePickbufferRectangle ()
 Toggles wheather the pickbuffer window should be displayed additionally.
 

Static Public Member Functions

static PickingHelpergetInstance ()
 Use this to access the object instance. More...
 

Public Attributes

bool m_useLinearScaling
 scaling function switch
 
bool m_useNaiveSearch
 search algorithm switch
 
bool m_showPickbufferRectangle
 pickbuffer rectangle visualization switch
 
bool m_showBubbleCursor
 bubble - / crosshair cursor switch
 
int m_pickingbuffer_window_width
 Search width and height in pixel, assuming the window is quadratic.
 

Private Member Functions

 PickingHelper ()
 PickingHelper class constructor.
 
void checkNN_sophisticated (const GLint *pickbuffer_window, const int x_size, const int y_size, const int x_center, const int y_center, int &id, double &distance)
 Searches pickbuffer window for nearest objects and returns the nearest objects ID and its euclidean distance to the mouse cursor. More...
 
void checkNN_naive (const GLint *pickbuffer_window, const int x_size, const int y_size, const int x_center, const int y_center, int &id, double &distance)
 Searches pickbuffer window for nearest objects and returns the nearest objects ID and its euclidean distance to the mouse cursor. More...
 
double mouse_scale_linear (double distance)
 Linear scaling function Returns a scaling factor based on the input euclidean distance. More...
 
double mouse_scale_inverse (double distance)
 Inverse scaling function Returns a scaling factor based on the input euclidean distance. More...
 

Private Attributes

double m_mouse_min_scale
 minimum scale function value
 
double m_mouse_max_scale
 maximum scale function value
 
double m_mouse_cutoff_distance
 Cutoff distance. More...
 
double m_mouse_scaling_exponent
 exponent in inverse scaling function
 

Static Private Attributes

static PickingHelpersingletonPointer = 0
 The singleton pointer.
 

Detailed Description

Semantic Pointing for Object Picking in Complex 3D Environments This file is responsible the non-opengl related calculations in our implementation.

Member Function Documentation

double PickingHelper::changeCutoffDistance ( double  deltaC)
inline

Use this method to safely change the Cutoff - distance required for the linear scaling function.

Parameters
deltaCdesired difference in cutoff distance.
Returns
the new value.
double PickingHelper::changeInverseExponent ( double  delta_S)
inline

Use this method to safely change the exponent of the inverse scale function.

its range is limited by [0.1, 50.0]

See also
m_mouse_scaling_exponent
Parameters
delta_Sdesired difference in exponent.
Returns
the new value.
double PickingHelper::changeMaxScale ( double  delta_M)
inline

Use this method to safely change the maximum value of the scale function interval.

its range is limited by [

See also
m_mouse_min_scale,
SCALE_MAX]
Parameters
delta_Mdesired difference in maximum interval.
Returns
the new value.
double PickingHelper::changeMinScale ( double  delta_m)
inline

Use this method to safely change the minumum value of the scale function interval.

its range is limited by [ SCALE_MIN, m_mouse_max_scale]

See also
SCALE_MIN
m_mouse_max_scale
Parameters
delta_mdesired difference in minimum interval.
Returns
the new value.
void PickingHelper::checkNN ( const GLint *  pickbuffer_window,
const int  x_size,
const int  y_size,
const int  x_center,
const int  y_center,
int &  id,
double &  distance 
)

Searches pickbuffer window for nearest objects and returns the nearest objects ID and its euclidean distance to the mouse cursor.

This method calls one of the private members

See also
checkNN_naive or
checkNN_sophisticated, depending on the flag m_useNaiveSearch.
Parameters
pickbuffer_windowThe pickbuffer window. It's supposed to contain object IDs > 0 whenever a pixel for a pickable object is drawn.
x_sizeAbsolute width of the pickbuffer window.
y_sizeAbsolute height of the pickbuffer window.
x_centerAbsolute mouse cursor x-location relative to pickbuffer_window origin.
y_centerAbsolute mouse cursor y-location relative to pickbuffer_window origin.
idStores the object ID of the nearest object. Will be 0 if no object is found.
distanceStores the euclidean distance from the mouse cursor to the nearest object. Will be
See also
DBL_MAX if no object is found.
void PickingHelper::checkNN_naive ( const GLint *  pickbuffer_window,
const int  x_size,
const int  y_size,
const int  x_center,
const int  y_center,
int &  id,
double &  distance 
)
private

Searches pickbuffer window for nearest objects and returns the nearest objects ID and its euclidean distance to the mouse cursor.

This is a naive implementation. It runs through all entries in the pickbuffer. Due to its simplicity it is very fast for small pickbuffer windows.

Parameters
pickbuffer_windowThe pickbuffer window. It's supposed to contain object IDs > 0 whenever a pixel for a pickable object is drawn.
x_sizeAbsolute width of the pickbuffer window.
y_sizeAbsolute height of the pickbuffer window.
x_centerAbsolute mouse cursor x-location relative to pickbuffer_window origin.
y_centerAbsolute mouse cursor y-location relative to pickbuffer_window origin.
idStores the object ID of the nearest object. Will be 0 if no object is found.
distanceStores the euclidean distance from the mouse cursor to the nearest object. Will be DBL_MAX
See also
DBL_MAX if no object is found.
void PickingHelper::checkNN_sophisticated ( const GLint *  pickbuffer_window,
const int  x_size,
const int  y_size,
const int  x_center,
const int  y_center,
int &  id,
double &  distance 
)
private

Searches pickbuffer window for nearest objects and returns the nearest objects ID and its euclidean distance to the mouse cursor.

This implementation is a bit more sophisticated, than the naive approach. It searches for nearest objects by growing the search region starting from the mouse center until it hits an object. This will increase search performance, as long as objects are nearby.

Parameters
pickbuffer_windowThe pickbuffer window. It's supposed to contain object IDs > 0 whenever a pixel for a pickable object is drawn.
x_sizeAbsolute width of the pickbuffer window.
y_sizeAbsolute height of the pickbuffer window.
x_centerAbsolute mouse cursor x-location relative to pickbuffer_window origin.
y_centerAbsolute mouse cursor y-location relative to pickbuffer_window origin.
idStores the object ID of the nearest object. Will be 0 if no object is found.
distanceStores the euclidean distance from the mouse cursor to the nearest object. Will be DBL_MAX
See also
DBL_MAX if no object is found.
PickingHelper * PickingHelper::getInstance ( )
static

Use this to access the object instance.

Returns
The singleton object instance
double PickingHelper::mouse_scale_inverse ( double  distance)
private

Inverse scaling function Returns a scaling factor based on the input euclidean distance.

See also
m_mouse_max_scale
m_mouse_min_scale
m_mouse_cutoff_distance
MOUSE_SCALING_CONSTANT
Parameters
distanceeuclidean distance.
Returns
scaling factor.
double PickingHelper::mouse_scale_linear ( double  distance)
private

Linear scaling function Returns a scaling factor based on the input euclidean distance.

See also
m_mouse_max_scale
m_mouse_min_scale
m_mouse_cutoff_distance
MOUSE_SCALING_CONSTANT
Parameters
distanceeuclidean distance.
Returns
scaling factor.
double PickingHelper::scale_by_distance ( double  distance)

Scaling function Calls either mouse_scale_linear or mouse_scale_inverse and returns the scale factor.

See also
m_mouse_cutoff_distance
MOUSE_SCALING_CONSTANT
Parameters
distanceeuclidean distance.
Returns
scaling factor in range [
See also
m_mouse_min_scale ,
m_mouse_max_scale].
double PickingHelper::springInput ( double  lastValue,
double  targetValue,
double  deltaTime,
double  springConstant = 6.0 
)

Uses Spring function to smooth out input.

Spring Equation used: out = targetValue + (lastValue-targetValue)*exp(-deltaTime*springConstant);

Parameters
lastValuethe last value of teh variable.
targetValueThe target value to smooth out.
deltaTimeTime elapsed since last frame.
springConstantSpring Constant. Is 6 by default
Returns
smoothed out value.
bool PickingHelper::toggleBubbleCursor ( )
inline

Toggles wheather the bubble cursor should be displayed or the standard cursor.

Returns
the boolean state.
bool PickingHelper::toggleLinearScaling ( )
inline

Toggles between usage of the linear- and the inverse scaling function.

Returns
the boolean state.
bool PickingHelper::toggleNaiveSearch ( )
inline

Toggles between usage of the naive- and the sophicticated pickbuffer search algorithm.

Returns
the boolean state.

Member Data Documentation

double PickingHelper::m_mouse_cutoff_distance
private

Cutoff distance.

If distance is higher than this threshold the maximum mouse scale factor will be output


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