CGPdocs

camera_projection_perspective

Perspective projection parameters (field of view, aspect ratio, near/far planes).

module 10_camera_modelsource: camera_projection.hpp
Side view of the view frustum: field_of_view is the full vertical angle in radians, depth_min and depth_max are distances in front of the camera, aspect_ratio is width over height.
Side view of the view frustum: field_of_view is the full vertical angle in radians, depth_min and depth_max are distances in front of the camera, aspect_ratio is width over height. Tap to enlarge.

Fields and methods

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

Fields

float field_of_view = 50.0f * Pi/180Vertical field of view in radians, 50 degrees by default.
float aspect_ratio = 1.0fWidth/height ratio of the viewport, 1 by default (usually set from window_structure::aspect_ratio()).
float depth_min = 0.01fDistance of the near clipping plane, 0.01 by default.
float depth_max = 1000Distance of the far clipping plane, 1000 by default.

Methods

Returns the 4x4 OpenGL perspective projection matrix built from field_of_view, aspect_ratio, depth_min and depth_max. src
Returns the inverse of the perspective projection matrix (normalized device coordinates to camera space). src

Functions taking a camera_projection_perspective

Compute 3

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_plane_orthogonal_to_cameraIntersects the camera ray through the screen position (relative coordinates) with the plane through plane_position orthogonal to the front direction of the camera.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

Functions returning a camera_projection_perspective

None.

Operators

None.

CGP - Computer Graphics Programming.