Picking

HOOPS Luminate offers a picking API to identify geometries that are found ‘under’ the mouse. There are several picking methods available in HOOPS Luminate:

  • RED::IWindow::FramePicking: The picking occurs for a small window defined around the mouse cursor coordinates. All objects and entities found within are returned.

  • RED::IWindow::FramePickingRectangle: The picking occurs for a rectangular area in the window. All objects found within are returned.

  • Lasso picking: This is not implemented using a single method. Please refer to the Picking using a Lasso example for all the details.

It’s important to mention that HOOPS Luminate picking methods are entirely based on CPU processing. The GPU is not involved in the resolution of picking. Also important, HOOPS Luminate picking is not based on ray intersection with triangles; By default, picking occurs for a pixel frustum pyramid being intersected with the scene, so that lines and points can be intersected and that would be missed otherwise if we were to only propagate a ray in the scene.

Picking Results

On calling one of the HOOPS Luminate picking methods, a RED::Vector of RED::ShapePath objects is returned. There’s one RED::ShapePath object created for each object being intersected by the picked rectangle fired from the camera eye position between the camera near and far clip distance:

../../../_images/shape_path_picking.png

Example of picking with a small selection window

Here, our pick window hits the three objects A, B and C. Then, we’ll find 3 RED::ShapePath objects in our returned vector from the RED::IWindow::FramePicking method. Then, each shape path object can contain informations on several hit points and primitives for each object. In the example above, for instance, if object A is double sided, the first shape path returned will store two RED::ShapePath::LeafData items in it, indicating the two intersections found during the process:

../../../_images/picking_dual_sided.png

Example of double sided geometry picking

Each RED::ShapePath::LeafData item will store informations on the hit primitive of the object (triangle, line segment, strip segment or point) as well as an estimation of the ‘best hit point’ to be used as the picking result. Because the picking is not based on ray propagation, and is rather based on pyramid propagation in the scene, there’s no unique solution to the intersection of a pyramid with a primitive. HOOPS Luminate looks for a best match point to be used as the picking result.

Picking results are sorted from the closest picked primitive to the farthest picked primitive.