HIRO_DRAW
Computer Graphics Structures library
hiro::draw::ProjectionParams Struct Reference

Projection, camera and viewport parameters. More...

Public Member Functions

glm::vec3 CastRay (const glm::vec2 &clip_coords) const
 Computes the direction of a ray casted form camera at a given 2D coordinates. More...
 
glm::vec2 ScreenToClipCoords (float x, float y) const
 Converts screen coordinates to clip coordinates. More...
 
geom::IRect GetViewport () const
 Returns viewport rectangle area.
 

Data Fields

int32_t top
 Viewport offset from the top window border. In pixels.
 
int32_t left
 Viewport offset from the left window border. In pixels.
 
int32_t bottom
 Viewport offset from the bottom window border. In pixels.
 
int32_t right
 Viewport offset from the right window border. In pixels.
 
float fov_x
 Horizontal view angle. In radians.
 
float fov_y
 Vertical view angle, In radians.
 
float near_distance
 Distance to near projection plane.
 
float far_distance
 Distance to far projection plane.
 
glm_ext::TransMat4 view
 Camera view matrix.
 
glm_ext::TransMat4 proj
 Projection matrix.
 
float width
 Horizontal pixel resolution of viewport.
 
float height
 Vertical pixel resolution of viewport.
 
float aspect
 Aspect ratio of a viewport (width/height);.
 

Detailed Description

Projection, camera and viewport parameters.

Member Function Documentation

◆ CastRay()

glm::vec3 hiro::draw::ProjectionParams::CastRay ( const glm::vec2 &  clip_coords) const

Computes the direction of a ray casted form camera at a given 2D coordinates.

clip_coords 2D coordinate in clip space used for ray generation. If you wish to convert screen coordinates to clip coordinates, see ScreenToClipCoords.

Returns
Direction of a generated ray. A starting position of a ray is usually camera position.

◆ ScreenToClipCoords()

glm::vec2 hiro::draw::ProjectionParams::ScreenToClipCoords ( float  x,
float  y 
) const

Converts screen coordinates to clip coordinates.

Screen coordinates are in pixels and are generated for example by mouse events. Clip coordinates are in the range -1.0 and 1.0 range and relative to the viewport.