CGPdocs

picking_structure

Result of a picking (picking_spheres...) with the selected index, the 3D position and the ray.

module 18_user_interactionssource: picking_structure.hpp

Fields and methods

Members of the struct picking_structure. Most of what you do with a CGP type goes through the free functions listed below.

Fields

bool activeTrue if the ray hit an element, false otherwise (the other fields except the ray are then not meaningful).
int indexIndex of the picked element in the array given to the picking function, -1 when nothing is picked.
vec3 position3D position of the hit point on the picked sphere.
vec3 normalNormal at the hit point: the sphere normal for picking_spheres, the vertex normal for picking_mesh_vertex_as_sphere.
vec3 ray_originOrigin of the picking ray, the position of the camera.
vec3 ray_directionUnit direction of the picking ray, through the clicked point of the screen.
vec2 screen_clickedClicked position in relative screen coordinates in [-1,1], as given to the picking function.

Methods

Builds an empty picking result: active false, index -1, zero vectors. src

Functions taking a picking_structure

None.

Functions returning a picking_structure

Compute 2

Documented on another page

  • picking_mesh_vertex_as_sphereCasts the camera ray through the screen position and returns the closest vertex whose sphere of radius picking_distance it hits, with the hit point, the vertex normal and the vertex index (active is false if none).on vec2
  • picking_spheresCast a ray through a screen position (normalized device coordinates) and return the closest hit among spheres of common radius, with its index, position and normal.on vec2

Operators

None.

CGP - Computer Graphics Programming.