Easy3D 2.5.3
Picker Class Reference

Base class for picking mechanism. More...

#include <easy3d/gui/picker.h>

Inheritance diagram for Picker:
ModelPicker PointCloudPicker SurfaceMeshPicker

Public Member Functions

 Picker (const Camera *cam)
 
const Cameracamera () const
 Returns the pointer of the camera.
 
Line3 picking_line (int x, int y) const
 Construct a picking line. More...
 
vec3 picking_dir (int x, int y) const
 The picking direction, pointing inside the screen. More...
 
vec3 project (const vec3 &p) const
 Project a 3D point in the world coordinate system onto the 2D screen coordinate system. More...
 
vec3 unproject (int x, int y, float depth) const
 Compute the world coordinates of a point defined in the screen coordinate system. More...
 
void screen_to_opengl (int x, int y, int &gl_x, int &gl_y, int width, int height) const
 Convert a point expressed in the screen coordinate system (with an origin in the upper left corner) into the OpenGL coordinate system (with an origin in the lower left corner). The high DPI scaling is also taken into consideration, so the result always corresponds to its image pixel. More...
 

Detailed Description

Base class for picking mechanism.

See also
ModelPicker, PointCloudPicker, SurfaceMeshPicker

Member Function Documentation

◆ picking_dir()

vec3 picking_dir ( int  x,
int  y 
) const
inline

The picking direction, pointing inside the screen.

Parameters
xThe cursor x-coordinate, relative to the left edge of the content area.
yThe cursor y-coordinate, relative to the top edge of the content area.
Attention
The screen point is expressed in the screen coordinate system with an origin in the upper left corner. So it doesn't necessarily correspond to a pixel on High DPI devices, e.g. a Mac with a Retina display.

◆ picking_line()

Line3 picking_line ( int  x,
int  y 
) const
inline

Construct a picking line.

Parameters
xThe cursor x-coordinate, relative to the left edge of the content area.
yThe cursor y-coordinate, relative to the top edge of the content area.
Attention
The screen point is expressed in the screen coordinate system with an origin in the upper left corner. So it doesn't necessarily correspond to a pixel on High DPI devices, e.g. a Mac with a Retina display.

◆ project()

vec3 project ( const vec3 p) const
inline

Project a 3D point in the world coordinate system onto the 2D screen coordinate system.

Parameters
pA 3D point in the world coordinate system.
Returns
The x and y components of the returned value denote the projected screen point expressed in the screen coordinate system, with (0, 0) being the upper left corner of the content area. The z component ranges between 0.0 (near plane) and 1.0 (excluded, far plane).
Attention
The screen point is expressed in the screen coordinate system with an origin in the upper left corner. So it doesn't necessarily correspond to a pixel on High DPI devices, e.g. a Mac with a Retina display.

◆ screen_to_opengl()

void screen_to_opengl ( int  x,
int  y,
int &  gl_x,
int &  gl_y,
int  width,
int  height 
) const

Convert a point expressed in the screen coordinate system (with an origin in the upper left corner) into the OpenGL coordinate system (with an origin in the lower left corner). The high DPI scaling is also taken into consideration, so the result always corresponds to its image pixel.

Parameters
xThe x-coordinate, relative to the left edge of the content area.
yThe y-coordinate, relative to the top edge of the content area.
gl_xReturns the x component of the point in the OpenGL coordinate system.
gl_yReturns the y component of the point in the OpenGL coordinate system.
widthThe width of the OpenGL viewport (may not be identical to the width of the screen in pixels).
heightThe width of the OpenGL viewport (may not be identical to the height of the screen in pixels).

◆ unproject()

vec3 unproject ( int  x,
int  y,
float  depth 
) const
inline

Compute the world coordinates of a point defined in the screen coordinate system.

Parameters
xThe cursor x-coordinate, relative to the left edge of the content area.
yThe cursor y-coordinate, relative to the top edge of the content area.
depthThe depth value of the screen point, ranging between 0.0 and 1.0 (excluded).
Returns
The world unprojected coordinates of the screen point.
Attention
The screen point is expressed in the screen coordinate system with an origin in the upper left corner. So it doesn't necessarily correspond to a pixel on High DPI devices, e.g. a Mac with a Retina display.

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