Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::camera Class Reference

Class representing a camera. Contains functionality for manipulating and updating a camera. It should not be used as a standalone class - see camera_component and the entity system. More...

#include <camera.h>

Inheritance diagram for unravel::camera:
crtp_meta_type< camera >

Public Member Functions

void set_projection_mode (projection_mode mode)
 Sets the current projection mode for this camera (i.e. orthographic or perspective).
 
void set_fov (float degrees)
 Sets the field of view angle of this camera (perspective only).
 
void set_near_clip (float distance)
 Sets the near plane distance.
 
void set_far_clip (float distance)
 Sets the far plane distance.
 
void set_orthographic_size (float size)
 Sets the half of the vertical size of the viewing volume in world units.
 
auto get_projection_mode () const -> projection_mode
 Retrieves the current projection mode for this camera.
 
auto get_fov () const -> float
 Retrieves the current field of view angle in degrees.
 
auto get_near_clip () const -> float
 Retrieves the distance from the camera to the near clip plane.
 
auto get_far_clip () const -> float
 Retrieves the distance from the camera to the far clip plane.
 
auto get_ortho_size () const -> float
 Retrieves the orthographic size.
 
auto get_zoom_factor () const -> float
 Retrieves the zoom factor.
 
auto get_ppu () const -> float
 Retrieves the pixels per unit (PPU).
 
void set_viewport_size (const usize32_t &viewport_size)
 Sets the size of the viewport.
 
void set_viewport_pos (const ipoint32_t &viewport_pos)
 Sets the position of the viewport.
 
auto get_viewport_size () const -> const usize32_t &
 Retrieves the size of the viewport.
 
auto get_viewport_pos () const -> const ipoint32_t &
 Retrieves the position of the viewport.
 
void set_aspect_ratio (float aspect, bool locked=false)
 Sets the aspect ratio to be used for generating the horizontal FOV angle (perspective only).
 
auto get_aspect_ratio () const -> float
 Retrieves the aspect ratio used to generate the horizontal FOV angle.
 
auto is_aspect_locked () const -> bool
 Determines if the aspect ratio is currently being updated by the render driver.
 
auto is_frustum_locked () const -> bool
 Checks if the frustum is currently locked.
 
void lock_frustum (bool locked)
 Locks or unlocks the frustum.
 
auto get_frustum () const -> const math::frustum &
 Retrieves the current camera object frustum.
 
auto get_clipping_volume () const -> const math::frustum &
 Retrieves the frustum representing the space between the camera position and its near plane.
 
auto get_projection () const -> const math::transform &
 Retrieves the current projection matrix.
 
auto get_prev_projection () const -> const math::transform &
 
auto get_view () const -> const math::transform &
 Retrieves the current view matrix.
 
auto get_prev_view () const -> const math::transform &
 
auto get_view_inverse () const -> const math::transform &
 
auto get_view_relative () const -> const math::transform &
 
auto get_prev_view_relative () const -> const math::transform &
 
auto get_view_inverse_relative () const -> const math::transform &
 
auto get_prev_view_projection () const -> math::transform
 Retrieves the previous view matrix.
 
auto get_prev_view_projection_relative () const -> math::transform
 
auto get_taa_prev_view_projection () const -> math::transform
 View-projection used for the previous rendered frame (before the latest jitter sample).
 
auto get_view_projection () const -> math::transform
 Retrieves the current view-projection matrix.
 
auto get_view_projection_relative () const -> math::transform
 
void record_current_matrices ()
 Makes a copy of the current view and projection matrices before they are changed.
 
void set_aa_data (const usize32_t &viewport_size, std::uint32_t temporal_frame_index, std::uint32_t temporal_aa_samples, taa_jitter_mode jitter_mode=taa_jitter_mode::progressive_golden, float jitter_amplitude=1.0f, float jitter_temporal_phase_scale=1.0f)
 Sets the current jitter value for temporal anti-aliasing.
 
auto get_aa_data () const -> const math::vec4 &
 Retrieves the anti-aliasing data.
 
auto classify_aabb (const math::bbox &bounds) const -> math::volume_query
 Determines if the specified AABB falls within the frustum.
 
auto test_aabb (const math::bbox &bounds) const -> bool
 Tests if the specified AABB is within the frustum.
 
auto classify_obb (const math::bbox &bounds, const math::transform &t) const -> math::volume_query
 Determines if the specified OBB is within the frustum.
 
auto test_obb (const math::bbox &bounds, const math::transform &t) const -> bool
 Tests if the specified OBB is within the frustum.
 
auto test_billboard (float size, const math::transform &t) const -> bool
 
auto viewport_to_ray (const math::vec2 &point, math::vec3 &vec_ray_start, math::vec3 &vec_ray_dir) const -> bool
 Converts the specified screen position into a ray origin and direction vector.
 
auto viewport_to_world (const math::vec2 &point, const math::plane &plane, math::vec3 &position_out, bool clip) const -> bool
 Converts a screen position into a world space position on the specified plane.
 
auto project_to_quad (const math::vec2 &viewport_point, const math::transform &quad_transform, uint32_t quad_width, uint32_t quad_height, math::vec2 &pixel_out) const -> bool
 Raycasts from viewport point onto a quad plane and returns pixel coordinates.
 
auto viewport_to_major_axis (const math::vec2 &point, const math::vec3 &axis_origin, math::vec3 &position_out, math::vec3 &major_axis_out) const -> bool
 Converts a screen position into a world space intersection point on a major axis plane.
 
auto viewport_to_major_axis (const math::vec2 &point, const math::vec3 &axis_origin, const math::vec3 &align_normal, math::vec3 &position_out, math::vec3 &major_axis_out) const -> bool
 Converts a screen position into a world space intersection point on a major axis plane.
 
auto viewport_to_camera (const math::vec3 &point, math::vec3 &position_out) const -> bool
 Converts a screen position into a camera space position at the near plane.
 
auto world_to_viewport (const math::vec3 &pos) const -> math::vec3
 Transforms a point from world space into screen space.
 
auto estimate_zoom_factor (const math::plane &plane) const -> float
 Estimates the zoom factor based on the specified plane.
 
auto estimate_zoom_factor (const math::vec3 &position) const -> float
 Estimates the zoom factor based on the specified position.
 
auto estimate_zoom_factor (const math::plane &plane, float maximum_value) const -> float
 Estimates the zoom factor based on the specified plane, constrained by a maximum value.
 
auto estimate_zoom_factor (const math::vec3 &position, float maximum_value) const -> float
 Estimates the zoom factor based on the specified position, constrained by a maximum value.
 
auto estimate_pick_tolerance (float pixel_tolerance, const math::vec3 &reference_position, const math::transform &object_transform) const -> math::vec3
 Estimates the pick tolerance based on the pixel tolerance and reference position.
 
void look_at (const math::vec3 &eye, const math::vec3 &at)
 Sets the camera to look at a specified target.
 
void look_at (const math::vec3 &eye, const math::vec3 &at, const math::vec3 &up)
 Sets the camera to look at a specified target with an up vector.
 
auto get_position () const -> const math::vec3 &
 Retrieves the current position of the camera.
 
auto x_unit_axis () const -> math::vec3
 Retrieves the x-axis unit vector of the camera's local coordinate system.
 
auto y_unit_axis () const -> math::vec3
 Retrieves the y-axis unit vector of the camera's local coordinate system.
 
auto z_unit_axis () const -> math::vec3
 Retrieves the z-axis unit vector of the camera's local coordinate system.
 
auto get_local_bounding_box () -> math::bbox
 Retrieves the bounding box of this object.
 
void touch ()
 Marks the camera as modified.
 
- Public Member Functions inherited from crtp_meta_type< camera >
virtual auto get_meta_type () const -> entt::meta_type
 
auto is () const -> bool
 
auto is (const entt::meta_type &type) const -> bool
 
virtual auto as_derived () -> entt::meta_any
 

Static Public Member Functions

static auto get_face_camera (std::uint32_t face, const math::transform &transform) -> camera
 Retrieves a camera for one of six cube faces.
 
- Static Public Member Functions inherited from crtp_meta_type< camera >
static auto get_static_meta_type () -> entt::meta_type
 

Protected Attributes

math::vec4 aa_data_ = {0.0f, 0.0f, 0.0f, 0.0f}
 Anti-aliasing data.
 
math::transform view_
 Cached view matrix.
 
math::transform view_inverse_
 
math::transform view_relative_
 
math::transform view_inverse_relative_
 
math::transform projection_
 Cached projection matrix.
 
math::transform last_view_
 Cached "previous" view matrix.
 
math::transform last_view_relative_
 
math::transform last_projection_
 Cached "previous" projection matrix.
 
math::transform taa_prev_view_
 Snapshot for temporal reprojection: view/projection before advancing jitter (see set_aa_data).
 
math::transform taa_prev_projection_
 
math::frustum frustum_
 Details regarding the camera frustum.
 
math::frustum clipping_volume_
 The near clipping volume (area of space between the camera position and the near plane).
 
projection_mode projection_mode_ = projection_mode::perspective
 The type of projection currently selected for this camera.
 
float fov_ = 60.0f
 Vertical degrees angle (perspective only).
 
float near_clip_ = 0.1f
 Near clip plane Distance.
 
float far_clip_ = 1000.0f
 Far clip plane Distance.
 
float ortho_size_ = 5
 camera's half-size when in orthographic mode.
 
float aspect_ratio_ = 1.0f
 The aspect ratio used to generate the correct horizontal degrees (perspective only)
 
ipoint32_t viewport_pos_ = {0, 0}
 Viewport position.
 
usize32_t viewport_size_ = {0, 0}
 Viewport size.
 
bool view_dirty_ = true
 View matrix dirty ?
 
bool projection_dirty_ = true
 Projection matrix dirty ?
 
bool aspect_dirty_ = true
 Has the aspect ratio changed?
 
bool frustum_dirty_ = true
 Are the frustum planes dirty ?
 
bool aspect_locked_ = false
 Should the aspect ratio be automatically updated by the render driver?
 
bool frustum_locked_ = false
 Is the frustum locked?
 

Detailed Description

Class representing a camera. Contains functionality for manipulating and updating a camera. It should not be used as a standalone class - see camera_component and the entity system.

Definition at line 61 of file camera.h.

Member Function Documentation

◆ classify_aabb()

auto unravel::camera::classify_aabb ( const math::bbox & bounds) const -> math::volume_query

Determines if the specified AABB falls within the frustum.

Parameters
boundsThe AABB to test.
Returns
The result of the volume query.

Definition at line 424 of file camera.cpp.

◆ classify_obb()

auto unravel::camera::classify_obb ( const math::bbox & bounds,
const math::transform & t ) const -> math::volume_query

Determines if the specified OBB is within the frustum.

Parameters
boundsThe OBB to test.
tThe transformation to apply to the OBB.
Returns
The result of the volume query.

Definition at line 442 of file camera.cpp.

◆ estimate_pick_tolerance()

auto unravel::camera::estimate_pick_tolerance ( float pixel_tolerance,
const math::vec3 & reference_position,
const math::transform & object_transform ) const -> math::vec3

Estimates the pick tolerance based on the pixel tolerance and reference position.

Parameters
pixel_toleranceThe pixel tolerance.
reference_positionThe reference position.
object_transformThe transformation to apply to the object.
Returns
The estimated pick tolerance.

Definition at line 745 of file camera.cpp.

◆ estimate_zoom_factor() [1/4]

auto unravel::camera::estimate_zoom_factor ( const math::plane & plane) const -> float

Estimates the zoom factor based on the specified plane.

Parameters
planeThe reference plane.
Returns
The estimated zoom factor.

Definition at line 675 of file camera.cpp.

◆ estimate_zoom_factor() [2/4]

auto unravel::camera::estimate_zoom_factor ( const math::plane & plane,
float maximum_value ) const -> float

Estimates the zoom factor based on the specified plane, constrained by a maximum value.

Parameters
planeThe reference plane.
maximum_valueThe maximum zoom factor value.
Returns
The estimated zoom factor.

Definition at line 708 of file camera.cpp.

◆ estimate_zoom_factor() [3/4]

auto unravel::camera::estimate_zoom_factor ( const math::vec3 & position) const -> float

Estimates the zoom factor based on the specified position.

Given the current viewport type and projection mode, estimate the "zoom" factor that can be used for scaling various operations relative to the "scale" of an object as it appears in the viewport at the specified position.

Parameters
positionThe reference position.
Returns
The estimated zoom factor.

Definition at line 703 of file camera.cpp.

◆ estimate_zoom_factor() [4/4]

auto unravel::camera::estimate_zoom_factor ( const math::vec3 & position,
float maximum_value ) const -> float

Estimates the zoom factor based on the specified position, constrained by a maximum value.

Parameters
positionThe reference position.
maximum_valueThe maximum zoom factor value.
Returns
The estimated zoom factor.

Definition at line 728 of file camera.cpp.

◆ get_aa_data()

auto unravel::camera::get_aa_data ( ) const -> const math::vec4&

Retrieves the anti-aliasing data.

Returns
The anti-aliasing data.

Definition at line 858 of file camera.cpp.

◆ get_aspect_ratio()

auto unravel::camera::get_aspect_ratio ( ) const -> float

Retrieves the aspect ratio used to generate the horizontal FOV angle.

Returns
The aspect ratio.

Definition at line 185 of file camera.cpp.

◆ get_clipping_volume()

auto unravel::camera::get_clipping_volume ( ) const -> const math::frustum&

Retrieves the frustum representing the space between the camera position and its near plane.

Returns
The clipping volume frustum.

Definition at line 412 of file camera.cpp.

◆ get_face_camera()

auto unravel::camera::get_face_camera ( std::uint32_t face,
const math::transform & transform ) -> camera
static

Retrieves a camera for one of six cube faces.

Parameters
faceThe index of the cube face.
transformThe transformation to apply.
Returns
The corresponding face camera.

Definition at line 872 of file camera.cpp.

◆ get_far_clip()

auto unravel::camera::get_far_clip ( ) const -> float

Retrieves the distance from the camera to the far clip plane.

Returns
The far clip distance.

Definition at line 69 of file camera.cpp.

◆ get_fov()

auto unravel::camera::get_fov ( ) const -> float

Retrieves the current field of view angle in degrees.

Returns
The field of view angle.

Definition at line 59 of file camera.cpp.

◆ get_frustum()

auto unravel::camera::get_frustum ( ) const -> const math::frustum&

Retrieves the current camera object frustum.

Returns
The current frustum.

Definition at line 372 of file camera.cpp.

◆ get_local_bounding_box()

auto unravel::camera::get_local_bounding_box ( ) -> math::bbox

Retrieves the bounding box of this object.

Returns
The local bounding box.

Definition at line 147 of file camera.cpp.

◆ get_near_clip()

auto unravel::camera::get_near_clip ( ) const -> float

Retrieves the distance from the camera to the near clip plane.

Returns
The near clip distance.

Definition at line 64 of file camera.cpp.

◆ get_ortho_size()

auto unravel::camera::get_ortho_size ( ) const -> float

Retrieves the orthographic size.

Returns
The orthographic size.

Definition at line 74 of file camera.cpp.

◆ get_position()

auto unravel::camera::get_position ( ) const -> const math::vec3&

Retrieves the current position of the camera.

Returns
The current camera position.

Definition at line 353 of file camera.cpp.

◆ get_ppu()

auto unravel::camera::get_ppu ( ) const -> float

Retrieves the pixels per unit (PPU).

Returns
The PPU value.

Definition at line 21 of file camera.cpp.

◆ get_prev_projection()

auto unravel::camera::get_prev_projection ( ) const -> const math::transform&

Definition at line 273 of file camera.cpp.

◆ get_prev_view()

auto unravel::camera::get_prev_view ( ) const -> const math::transform&

Definition at line 283 of file camera.cpp.

◆ get_prev_view_projection()

auto unravel::camera::get_prev_view_projection ( ) const -> math::transform

Retrieves the previous view matrix.

Returns
The previous view matrix.

Definition at line 313 of file camera.cpp.

◆ get_prev_view_projection_relative()

auto unravel::camera::get_prev_view_projection_relative ( ) const -> math::transform

Definition at line 328 of file camera.cpp.

◆ get_prev_view_relative()

auto unravel::camera::get_prev_view_relative ( ) const -> const math::transform&

Definition at line 293 of file camera.cpp.

◆ get_projection()

auto unravel::camera::get_projection ( ) const -> const math::transform&

Retrieves the current projection matrix.

Returns
The current projection matrix.

Definition at line 205 of file camera.cpp.

◆ get_projection_mode()

auto unravel::camera::get_projection_mode ( ) const -> projection_mode

Retrieves the current projection mode for this camera.

Returns
The current projection mode.

Definition at line 54 of file camera.cpp.

◆ get_taa_prev_view_projection()

auto unravel::camera::get_taa_prev_view_projection ( ) const -> math::transform

View-projection used for the previous rendered frame (before the latest jitter sample).

Updated inside set_aa_data(); use for temporal reprojection (TAA) so history aligns with jittered projection.

Definition at line 318 of file camera.cpp.

◆ get_view()

auto unravel::camera::get_view ( ) const -> const math::transform&

Retrieves the current view matrix.

Returns
The current view matrix.

Definition at line 278 of file camera.cpp.

◆ get_view_inverse()

auto unravel::camera::get_view_inverse ( ) const -> const math::transform&

Definition at line 298 of file camera.cpp.

◆ get_view_inverse_relative()

auto unravel::camera::get_view_inverse_relative ( ) const -> const math::transform&

Definition at line 303 of file camera.cpp.

◆ get_view_projection()

auto unravel::camera::get_view_projection ( ) const -> math::transform

Retrieves the current view-projection matrix.

Returns
The current view-projection matrix.

Definition at line 308 of file camera.cpp.

◆ get_view_projection_relative()

auto unravel::camera::get_view_projection_relative ( ) const -> math::transform

Definition at line 323 of file camera.cpp.

◆ get_view_relative()

auto unravel::camera::get_view_relative ( ) const -> const math::transform&

Definition at line 288 of file camera.cpp.

◆ get_viewport_pos()

auto unravel::camera::get_viewport_pos ( ) const -> const ipoint32_t&

Retrieves the position of the viewport.

Returns
The position of the viewport.

Definition at line 42 of file camera.cpp.

◆ get_viewport_size()

auto unravel::camera::get_viewport_size ( ) const -> const usize32_t&

Retrieves the size of the viewport.

Returns
The size of the viewport.

Definition at line 37 of file camera.cpp.

◆ get_zoom_factor()

auto unravel::camera::get_zoom_factor ( ) const -> float

Retrieves the zoom factor.

Returns
The zoom factor.

Definition at line 11 of file camera.cpp.

◆ is_aspect_locked()

auto unravel::camera::is_aspect_locked ( ) const -> bool

Determines if the aspect ratio is currently being updated by the render driver.

Returns
true if the aspect ratio is locked, false otherwise.

Definition at line 190 of file camera.cpp.

◆ is_frustum_locked()

auto unravel::camera::is_frustum_locked ( ) const -> bool

Checks if the frustum is currently locked.

Returns
true if the frustum is locked, false otherwise.

Definition at line 195 of file camera.cpp.

◆ lock_frustum()

void unravel::camera::lock_frustum ( bool locked)

Locks or unlocks the frustum.

Parameters
lockedWhether the frustum should be locked.

Definition at line 200 of file camera.cpp.

◆ look_at() [1/2]

void unravel::camera::look_at ( const math::vec3 & eye,
const math::vec3 & at )

Sets the camera to look at a specified target.

Parameters
eyeThe eye position.
atThe target position.

Definition at line 333 of file camera.cpp.

◆ look_at() [2/2]

void unravel::camera::look_at ( const math::vec3 & eye,
const math::vec3 & at,
const math::vec3 & up )

Sets the camera to look at a specified target with an up vector.

Parameters
eyeThe eye position.
atThe target position.
vUpThe up vector.

Definition at line 338 of file camera.cpp.

◆ project_to_quad()

auto unravel::camera::project_to_quad ( const math::vec2 & viewport_point,
const math::transform & quad_transform,
uint32_t quad_width,
uint32_t quad_height,
math::vec2 & pixel_out ) const -> bool

Raycasts from viewport point onto a quad plane and returns pixel coordinates.

Projects the viewport point through the camera onto the quad's plane, then converts the world intersection to local quad space and finally to document pixel coordinates. Assumes the quad is a unit quad (-0.5 to 0.5) scaled by the transform.

Parameters
viewport_pointThe viewport/screen position.
quad_transformThe quad's model transform (world * scale for world size).
quad_widthThe quad width in pixels.
quad_heightThe quad height in pixels.
pixel_outThe output pixel coordinates (0..width, 0..height), or (-1,-1) if no hit.
Returns
true if the ray hit the quad plane, false otherwise.

Definition at line 582 of file camera.cpp.

◆ record_current_matrices()

void unravel::camera::record_current_matrices ( )

Makes a copy of the current view and projection matrices before they are changed.

Definition at line 759 of file camera.cpp.

◆ set_aa_data()

void unravel::camera::set_aa_data ( const usize32_t & viewport_size,
std::uint32_t temporal_frame_index,
std::uint32_t temporal_aa_samples,
taa_jitter_mode jitter_mode = taa_jitter_mode::progressive_golden,
float jitter_amplitude = 1.0f,
float jitter_temporal_phase_scale = 1.0f )

Sets the current jitter value for temporal anti-aliasing.

Parameters
viewport_sizeViewport size (pixels) for scaling jitter into clip space.
temporal_frame_indexMonotonic frame counter (e.g. render frame). Drives progressive subpixel jitter (no short-period MSAA-style cycling); avoid large discontinuities.
temporal_aa_samplesValues > 1 enable jitter; count is stored for UI / future tuning.
jitter_modeWhich subpixel sequence to use (see taa_jitter_mode).
jitter_amplitudeScales raw subpixel offsets before clip scaling; 1 = full ~±½ pixel. Lower values (e.g. 0.5–0.7) reduce visible whole-frame shake at some AA cost.
jitter_temporal_phase_scaleMultiplies progression speed for golden / Halton / R2 (1 = legacy). MSAA rotating modes ignore this and advance one subsample per frame.

Definition at line 767 of file camera.cpp.

◆ set_aspect_ratio()

void unravel::camera::set_aspect_ratio ( float aspect,
bool locked = false )

Sets the aspect ratio to be used for generating the horizontal FOV angle (perspective only).

Parameters
aspectThe aspect ratio to set.
lockedWhether the aspect ratio should be locked.

Definition at line 167 of file camera.cpp.

◆ set_far_clip()

void unravel::camera::set_far_clip ( float distance)

Sets the far plane distance.

Parameters
distanceThe distance to the far clipping plane.

Definition at line 127 of file camera.cpp.

◆ set_fov()

void unravel::camera::set_fov ( float degrees)

Sets the field of view angle of this camera (perspective only).

Parameters
degreesThe field of view in degrees.

Definition at line 79 of file camera.cpp.

◆ set_near_clip()

void unravel::camera::set_near_clip ( float distance)

Sets the near plane distance.

Parameters
distanceThe distance to the near clipping plane.

Definition at line 107 of file camera.cpp.

◆ set_orthographic_size()

void unravel::camera::set_orthographic_size ( float size)

Sets the half of the vertical size of the viewing volume in world units.

Parameters
sizeThe size to set.

Definition at line 47 of file camera.cpp.

◆ set_projection_mode()

void unravel::camera::set_projection_mode ( projection_mode mode)

Sets the current projection mode for this camera (i.e. orthographic or perspective).

Parameters
modeThe projection mode to set.

Definition at line 93 of file camera.cpp.

◆ set_viewport_pos()

void unravel::camera::set_viewport_pos ( const ipoint32_t & viewport_pos)

Sets the position of the viewport.

Parameters
viewportPosThe position of the viewport.

Definition at line 32 of file camera.cpp.

◆ set_viewport_size()

void unravel::camera::set_viewport_size ( const usize32_t & viewport_size)

Sets the size of the viewport.

Parameters
viewportSizeThe size of the viewport.

Definition at line 26 of file camera.cpp.

◆ test_aabb()

auto unravel::camera::test_aabb ( const math::bbox & bounds) const -> bool

Tests if the specified AABB is within the frustum.

Parameters
boundsThe AABB to test.
Returns
true if the AABB is within the frustum, false otherwise.

Definition at line 433 of file camera.cpp.

◆ test_billboard()

auto unravel::camera::test_billboard ( float size,
const math::transform & t ) const -> bool

Definition at line 460 of file camera.cpp.

◆ test_obb()

auto unravel::camera::test_obb ( const math::bbox & bounds,
const math::transform & t ) const -> bool

Tests if the specified OBB is within the frustum.

Parameters
boundsThe OBB to test.
tThe transformation to apply to the OBB.
Returns
true if the OBB is within the frustum, false otherwise.

Definition at line 451 of file camera.cpp.

◆ touch()

void unravel::camera::touch ( )

Marks the camera as modified.

Definition at line 863 of file camera.cpp.

◆ viewport_to_camera()

auto unravel::camera::viewport_to_camera ( const math::vec3 & point,
math::vec3 & position_out ) const -> bool

Converts a screen position into a camera space position at the near plane.

Parameters
pointThe screen position.
position_outThe output camera space position.
Returns
true if the conversion is successful, false otherwise.

Definition at line 661 of file camera.cpp.

◆ viewport_to_major_axis() [1/2]

auto unravel::camera::viewport_to_major_axis ( const math::vec2 & point,
const math::vec3 & axis_origin,
const math::vec3 & align_normal,
math::vec3 & position_out,
math::vec3 & major_axis_out ) const -> bool

Converts a screen position into a world space intersection point on a major axis plane.

Parameters
pointThe screen position.
axis_originThe origin of the axis.
align_normalThe alignment normal.
position_outThe output world space position.
major_axis_outThe output major axis.
Returns
true if the conversion is successful, false otherwise.

Definition at line 618 of file camera.cpp.

◆ viewport_to_major_axis() [2/2]

auto unravel::camera::viewport_to_major_axis ( const math::vec2 & point,
const math::vec3 & axis_origin,
math::vec3 & position_out,
math::vec3 & major_axis_out ) const -> bool

Converts a screen position into a world space intersection point on a major axis plane.

Parameters
pointThe screen position.
axis_originThe origin of the axis.
position_outThe output world space position.
major_axis_outThe output major axis.
Returns
true if the conversion is successful, false otherwise.

Definition at line 610 of file camera.cpp.

◆ viewport_to_ray()

auto unravel::camera::viewport_to_ray ( const math::vec2 & point,
math::vec3 & vec_ray_start,
math::vec3 & vec_ray_dir ) const -> bool

Converts the specified screen position into a ray origin and direction vector.

Parameters
pointThe screen position.
rayOriginOutThe output ray origin.
rayDirectionOutThe output ray direction.
Returns
true if the conversion is successful, false otherwise.

Definition at line 497 of file camera.cpp.

◆ viewport_to_world()

auto unravel::camera::viewport_to_world ( const math::vec2 & point,
const math::plane & plane,
math::vec3 & position_out,
bool clip ) const -> bool

Converts a screen position into a world space position on the specified plane.

Parameters
pointThe screen position.
planeThe plane to intersect.
position_outThe output world space position.
clipWhether to clip the result.
Returns
true if the conversion is successful, false otherwise.

Definition at line 530 of file camera.cpp.

◆ world_to_viewport()

auto unravel::camera::world_to_viewport ( const math::vec3 & pos) const -> math::vec3

Transforms a point from world space into screen space.

Parameters
posThe world space position.
Returns
The screen space position.

Definition at line 473 of file camera.cpp.

◆ x_unit_axis()

auto unravel::camera::x_unit_axis ( ) const -> math::vec3

Retrieves the x-axis unit vector of the camera's local coordinate system.

Returns
The x-axis unit vector.

Definition at line 358 of file camera.cpp.

◆ y_unit_axis()

auto unravel::camera::y_unit_axis ( ) const -> math::vec3

Retrieves the y-axis unit vector of the camera's local coordinate system.

Returns
The y-axis unit vector.

Definition at line 362 of file camera.cpp.

◆ z_unit_axis()

auto unravel::camera::z_unit_axis ( ) const -> math::vec3

Retrieves the z-axis unit vector of the camera's local coordinate system.

Returns
The z-axis unit vector.

Definition at line 367 of file camera.cpp.

Member Data Documentation

◆ aa_data_

math::vec4 unravel::camera::aa_data_ = {0.0f, 0.0f, 0.0f, 0.0f}
protected

Anti-aliasing data.

Definition at line 541 of file camera.h.

◆ aspect_dirty_

bool unravel::camera::aspect_dirty_ = true
mutableprotected

Has the aspect ratio changed?

Definition at line 586 of file camera.h.

◆ aspect_locked_

bool unravel::camera::aspect_locked_ = false
protected

Should the aspect ratio be automatically updated by the render driver?

Definition at line 590 of file camera.h.

◆ aspect_ratio_

float unravel::camera::aspect_ratio_ = 1.0f
protected

The aspect ratio used to generate the correct horizontal degrees (perspective only)

Definition at line 576 of file camera.h.

◆ clipping_volume_

math::frustum unravel::camera::clipping_volume_
mutableprotected

The near clipping volume (area of space between the camera position and the near plane).

Definition at line 564 of file camera.h.

◆ far_clip_

float unravel::camera::far_clip_ = 1000.0f
protected

Far clip plane Distance.

Definition at line 572 of file camera.h.

◆ fov_

float unravel::camera::fov_ = 60.0f
protected

Vertical degrees angle (perspective only).

Definition at line 568 of file camera.h.

◆ frustum_

math::frustum unravel::camera::frustum_
mutableprotected

Details regarding the camera frustum.

Definition at line 562 of file camera.h.

◆ frustum_dirty_

bool unravel::camera::frustum_dirty_ = true
mutableprotected

Are the frustum planes dirty ?

Definition at line 588 of file camera.h.

◆ frustum_locked_

bool unravel::camera::frustum_locked_ = false
protected

Is the frustum locked?

Definition at line 592 of file camera.h.

◆ last_projection_

math::transform unravel::camera::last_projection_
protected

Cached "previous" projection matrix.

Definition at line 556 of file camera.h.

◆ last_view_

math::transform unravel::camera::last_view_
protected

Cached "previous" view matrix.

Definition at line 552 of file camera.h.

◆ last_view_relative_

math::transform unravel::camera::last_view_relative_
protected

Definition at line 553 of file camera.h.

◆ near_clip_

float unravel::camera::near_clip_ = 0.1f
protected

Near clip plane Distance.

Definition at line 570 of file camera.h.

◆ ortho_size_

float unravel::camera::ortho_size_ = 5
protected

camera's half-size when in orthographic mode.

Definition at line 574 of file camera.h.

◆ projection_

math::transform unravel::camera::projection_
mutableprotected

Cached projection matrix.

Definition at line 550 of file camera.h.

◆ projection_dirty_

bool unravel::camera::projection_dirty_ = true
mutableprotected

Projection matrix dirty ?

Definition at line 584 of file camera.h.

◆ projection_mode_

projection_mode unravel::camera::projection_mode_ = projection_mode::perspective
protected

The type of projection currently selected for this camera.

Definition at line 566 of file camera.h.

◆ taa_prev_projection_

math::transform unravel::camera::taa_prev_projection_
protected

Definition at line 560 of file camera.h.

◆ taa_prev_view_

math::transform unravel::camera::taa_prev_view_
protected

Snapshot for temporal reprojection: view/projection before advancing jitter (see set_aa_data).

Definition at line 559 of file camera.h.

◆ view_

math::transform unravel::camera::view_
protected

Cached view matrix.

Definition at line 543 of file camera.h.

◆ view_dirty_

bool unravel::camera::view_dirty_ = true
protected

View matrix dirty ?

Definition at line 582 of file camera.h.

◆ view_inverse_

math::transform unravel::camera::view_inverse_
protected

Definition at line 544 of file camera.h.

◆ view_inverse_relative_

math::transform unravel::camera::view_inverse_relative_
protected

Definition at line 547 of file camera.h.

◆ view_relative_

math::transform unravel::camera::view_relative_
protected

Definition at line 546 of file camera.h.

◆ viewport_pos_

ipoint32_t unravel::camera::viewport_pos_ = {0, 0}
protected

Viewport position.

Definition at line 578 of file camera.h.

◆ viewport_size_

usize32_t unravel::camera::viewport_size_ = {0, 0}
protected

Viewport size.

Definition at line 580 of file camera.h.


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