| VRS - The Virtual Rendering System |
| version 3.3 |
#include <vrs/sg/scenepicker.h>

Public Types | |
| typedef Callback3< SO < Iterator< PickResult > >, unsigned int, unsigned int > | SelectionCallback |
| typedef CallbackR1< unsigned int, SO< Shape > > | IdCreationCallback |
Public Member Functions | |
| ScenePicker (SO< SceneThing > scene, SO< IdCreationCallback > idCreationCallback, SO< SelectionCallback > pickingCallback, SO< GLCanvas > canvas, unsigned int textureUnit, unsigned int numberOfIdsToReserve=10000, bool renderPositionBuffer=true, SO< Iterator< ScenePicker::MouseButtonFunctionID > > buttonFunctionsToRegister=0) | |
| void | setupFBO (SO< GLCanvas > canvas) |
| virtual void | onActivation () |
| Called each time a InteractionTechnique is activated, i.e. | |
| virtual void | onDeactivation () |
| Called each time a InteractionTechnique is deactivated, i.e. | |
| virtual void | onDragStart (int x, int y, SO< ButtonEvent >, MouseButtonFunctionID id) |
| virtual void | onDragMotion (int x, int y, SO< MotionEvent >, MouseButtonFunctionID id, int startX, int startY) |
| virtual void | onDragEnd (int x, int y, SO< ButtonEvent >, MouseButtonFunctionID id, int startX, int startY) |
| virtual void | onEvent (SO< Event > e) |
| For each incoming event the base class checks the event type and passes the event to the corresponding virtual method. | |
| void | updatePickingBuffers () |
| This method updates the lookup image(s) for picking. | |
| bool | preservingViewDirectionRequired () |
| Rendered Id buffers are view dependent. | |
| bool | getRangeSelectionEnabled () const |
| void | setRangeSelectionEnabled (bool val) |
| Enables or Disables selection of multiple Objects by dragging a rectangle over the view plane. | |
| void | registerSelectionCallback (const SO< SelectionCallback > newSelectionCallback) |
| Register a callback which is called in case of picking If the "callOnNoHit" flag is set the method is also called when no (registered) geometry was hit. | |
| void | unregisterSelectionCallback (const SO< SelectionCallback > exisitingSelectioncallback) |
| void | clearSelectionCallbacks () |
| void | assignIdValues (SO< SceneThing > scene, SO< IdCreationCallback > idCreationCallback, unsigned int numberOfIdValues, unsigned int startId=0) |
| Creates a mapping from ids returned by the given callback to PolygonSets contained in the given scene. | |
| void | setSceneForRender (SO< SceneThing > scene) |
| Sets the scene containing the visible content. | |
| const Vector | addPolygonSet (unsigned int id, SO< PolygonSet > pset, bool updateLookupTexture=false) |
| Makes the polygon set identifiable by assigning the id. | |
| void | incrementTextureCoordinate () |
| SO< Iterator< Vector > > | addPolygonSets (SO< Iterator< unsigned int > > ids, SO< Iterator< SO< PolygonSet > > > psets, bool updateLookupTexture=false) |
| Makes the polygon set identifiable by assigning an id per polygonset. | |
| SO< Iterator< Vector > > | addPolygonSets (SO< Iterator< unsigned int > > ids, SO< Iterator< SO< Iterator< SO< PolygonSet > > > > > psets, bool updateLookupTexture=false) |
| Assign ids to groups of polygonsets. | |
| void | addSceneThing (SO< SceneThing > scene, unsigned int id, bool updateLookupTexture=false) |
| Assigns the given id to every PolygonSet in the given scene. | |
| const SO< GLImage > | getPixelPositions () const |
| const SO< GLImage > | getIdBufferImage () |
| const bool | getCameraSpaceCoordinateForPixel (unsigned int x, unsigned int y, Vector &coordinate) const |
| Reads the position in camera space coordinates associated with the pixel displayed To obtain world space coordinates the camera for the specific object / pixel must be known. | |
| const unsigned int | getIdForPixel (unsigned int x, unsigned int y) const |
| Reads the object id of the object displayed at the given pixel position. | |
| bool | getCallOnNoHit () const |
| void | setCallOnNoHit (bool val) |
| bool | ScenePicker::hasUnassignedIds (unsigned int numberOfRequiredIds) |
| unsigned int | getTextureUnit () |
| VRS_TYPEINFO (ScenePicker, InteractionTechnique) | |
Static Public Member Functions | |
| static VRS::UINT32 | getIdForColor (const Color &c) |
| static Color | getColorForId (VRS::UINT32 id) |
| static unsigned int | ScenePicker::getPixelForCoordinate (float coordinate, unsigned int size) |
| Calculates the pixel corresponding to the given coordinate in one dimension. | |
| static float | getCoordinateForPixel (unsigned pixel, unsigned int size) |
Static Public Attributes | |
| static const MouseButtonFunctionID | pickFunction |
Classes | |
| class | GLImage |
| struct | PickResult |
Once initialized with a scene an id is assigned to each polygonset using an ID texture and an additional texture coordinate channel. Afterwards the identification color image has to be updated when the scene view changes or the canvas is resized. After registering a scene the polygonsets can be merged or transformed as long as the texture coordinates stay the same.
| typedef Callback3<SO<Iterator<PickResult> >,unsigned int, unsigned int> VRS::ScenePicker::SelectionCallback |
| typedef CallbackR1<unsigned int,SO<Shape> > VRS::ScenePicker::IdCreationCallback |
| VRS::ScenePicker::ScenePicker | ( | SO< SceneThing > | scene, | |
| SO< IdCreationCallback > | idCreationCallback, | |||
| SO< SelectionCallback > | pickingCallback, | |||
| SO< GLCanvas > | canvas, | |||
| unsigned int | textureUnit, | |||
| unsigned int | numberOfIdsToReserve = 10000, |
|||
| bool | renderPositionBuffer = true, |
|||
| SO< Iterator< ScenePicker::MouseButtonFunctionID > > | buttonFunctionsToRegister = 0 | |||
| ) |
| SO<SceneThing> scene | ||
| SO<IdCreationCallback> idCreationCallback Function or method receiving a SO<Shape> and returning an id in the range of [1,MAXUINT] | ||
| SO<SelectionCallback> pickingCallback | ||
| SO<GLCanvas> canvas | ||
| unsigned int textureUnit | ||
| unsigned int numberOfIdsToReserve Maxium number of Ids that should be given. Defines the pixel size of the id image. | ||
| bool renderPositionBuffer | ||
| buttonFunctionsToRegister Additional ids to register (each id can be connected with one mouse button / modifier combination). The Sceen |
| virtual void VRS::ScenePicker::onActivation | ( | ) | [virtual] |
Called each time a InteractionTechnique is activated, i.e.
selected as active Interaction of a InteractionMode. It can be implemented by derivatives to initialize internal parameters.
Reimplemented from VRS::InteractionTechnique.
| virtual void VRS::ScenePicker::onDeactivation | ( | ) | [virtual] |
Called each time a InteractionTechnique is deactivated, i.e.
deselected as active Interaction of a InteractionMode. It can be implemented by derivatives to reset internal parameters.
Reimplemented from VRS::InteractionTechnique.
| virtual void VRS::ScenePicker::onDragStart | ( | int | x, | |
| int | y, | |||
| SO< ButtonEvent > | , | |||
| MouseButtonFunctionID | id | |||
| ) | [virtual] |
| virtual void VRS::ScenePicker::onDragMotion | ( | int | x, | |
| int | y, | |||
| SO< MotionEvent > | , | |||
| MouseButtonFunctionID | id, | |||
| int | startX, | |||
| int | startY | |||
| ) | [virtual] |
| virtual void VRS::ScenePicker::onDragEnd | ( | int | x, | |
| int | y, | |||
| SO< ButtonEvent > | , | |||
| MouseButtonFunctionID | id, | |||
| int | startX, | |||
| int | startY | |||
| ) | [virtual] |
For each incoming event the base class checks the event type and passes the event to the corresponding virtual method.
In addition each event() method is called for each event.
Reimplemented from VRS::InteractionTechnique.
| void VRS::ScenePicker::updatePickingBuffers | ( | ) |
This method updates the lookup image(s) for picking.
| bool VRS::ScenePicker::preservingViewDirectionRequired | ( | ) | [inline] |
Rendered Id buffers are view dependent.
Force the view direction to be preserved. Does always return 'false'
| bool VRS::ScenePicker::getRangeSelectionEnabled | ( | ) | const [inline] |
| void VRS::ScenePicker::setRangeSelectionEnabled | ( | bool | val | ) | [inline] |
Enables or Disables selection of multiple Objects by dragging a rectangle over the view plane.
| void VRS::ScenePicker::registerSelectionCallback | ( | const SO< SelectionCallback > | newSelectionCallback | ) |
Register a callback which is called in case of picking If the "callOnNoHit" flag is set the method is also called when no (registered) geometry was hit.
The id for this case is 0; The position included in the result is in Camera coordinates. Apply the inverse Orientation Matrix to get World Coordinates
| const SO<SelectionCallback> newSelectionCallback Function or Method callback taking the id of the object and the position of the pixel which has been hit. |
| void VRS::ScenePicker::unregisterSelectionCallback | ( | const SO< SelectionCallback > | exisitingSelectioncallback | ) |
| void VRS::ScenePicker::clearSelectionCallbacks | ( | ) |
| void VRS::ScenePicker::assignIdValues | ( | SO< SceneThing > | scene, | |
| SO< IdCreationCallback > | idCreationCallback, | |||
| unsigned int | numberOfIdValues, | |||
| unsigned int | startId = 0 | |||
| ) |
Creates a mapping from ids returned by the given callback to PolygonSets contained in the given scene.
| SO<SceneThing> scene Scene containing the objects to be destinguished | ||
| SO<CallbackR1<unsigned int,SO<PolygonSet> > > idCreationCallback CallbackFunction or method that returns an identifier for the given Polygonset. The id returned must be included in the interval [1,MAXUINT-1). Otherwise an exeption will be thrown. | ||
| numberOfIdValues | Number of distinct element ids that should be reserved. Influences the size of the id texture generated. |
| void VRS::ScenePicker::setSceneForRender | ( | SO< SceneThing > | scene | ) |
Sets the scene containing the visible content.
A camera must be contained in the scene. The scene can be an optimized version of the id-assigned scene which has been processed by assignIdValues as long as the generated texture coordinates are still available at the right place.
| SO<SceneThing> scene Scene containing all PolygonSets which shall be pickable. It must contain a scene camera and therefore be displayed equally on the canvas |
| const Vector VRS::ScenePicker::addPolygonSet | ( | unsigned int | id, | |
| SO< PolygonSet > | pset, | |||
| bool | updateLookupTexture = false | |||
| ) |
Makes the polygon set identifiable by assigning the id.
The id is only assigned if there are enough ids left in the id image. Otherwise an exception is thrown.
| unsigned int id | ||
| SO<PolygonSet> pset | ||
| bool updateLookupTexture Call updateTextures after entry creation |
| void VRS::ScenePicker::incrementTextureCoordinate | ( | ) |
| SO<Iterator<Vector> > VRS::ScenePicker::addPolygonSets | ( | SO< Iterator< unsigned int > > | ids, | |
| SO< Iterator< SO< PolygonSet > > > | psets, | |||
| bool | updateLookupTexture = false | |||
| ) |
Makes the polygon set identifiable by assigning an id per polygonset.
The iterators of ids and polygonsets must have an equal length
| SO<Iterator<unsigned int> > ids ids to assing to corresponding polygonset | ||
| SO<Iterator<SO<PolygonSet> > > psets Polygonsets | ||
| bool updateLookupTexture |
| void VRS::ScenePicker::addSceneThing | ( | SO< SceneThing > | scene, | |
| unsigned int | id, | |||
| bool | updateLookupTexture = false | |||
| ) |
Assigns the given id to every PolygonSet in the given scene.
| SO<SceneThing> scene | ||
| unsigned int id | ||
| bool updateLookupTexture |
| const bool VRS::ScenePicker::getCameraSpaceCoordinateForPixel | ( | unsigned int | x, | |
| unsigned int | y, | |||
| Vector & | coordinate | |||
| ) | const |
Reads the position in camera space coordinates associated with the pixel displayed To obtain world space coordinates the camera for the specific object / pixel must be known.
| unsigned int x X position in screen coordinates | ||
| unsigned int y Y Position in screen coordinates | ||
| Vector & coordinate in/out parameter holding the position value after successful read |
| const unsigned int VRS::ScenePicker::getIdForPixel | ( | unsigned int | x, | |
| unsigned int | y | |||
| ) | const |
Reads the object id of the object displayed at the given pixel position.
| unsigned int x | ||
| unsigned int y |
| bool VRS::ScenePicker::getCallOnNoHit | ( | ) | const [inline] |
| void VRS::ScenePicker::setCallOnNoHit | ( | bool | val | ) | [inline] |
| static VRS::UINT32 VRS::ScenePicker::getIdForColor | ( | const Color & | c | ) | [static] |
| static Color VRS::ScenePicker::getColorForId | ( | VRS::UINT32 | id | ) | [static] |
| static unsigned int VRS::ScenePicker::ScenePicker::getPixelForCoordinate | ( | float | coordinate, | |
| unsigned int | size | |||
| ) | [static] |
Calculates the pixel corresponding to the given coordinate in one dimension.
| float coordinate Texture coordinate in [0,1] | ||
| unsigned int size number of pixel in the required dimension |
| static float VRS::ScenePicker::getCoordinateForPixel | ( | unsigned | pixel, | |
| unsigned int | size | |||
| ) | [static] |
| bool VRS::ScenePicker::ScenePicker::hasUnassignedIds | ( | unsigned int | numberOfRequiredIds | ) |
| unsigned int VRS::ScenePicker::getTextureUnit | ( | ) | [inline] |
| VRS::ScenePicker::VRS_TYPEINFO | ( | ScenePicker | , | |
| InteractionTechnique | ||||
| ) |
const MouseButtonFunctionID VRS::ScenePicker::pickFunction [static] |