Unravel Engine C++ 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>
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 &viewportSize) |
Sets the size of the viewport. | |
void | set_viewport_pos (const upoint32_t &viewportPos) |
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 upoint32_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_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 &viewportSize, std::uint32_t currentSubpixelIndex, std::uint32_t temporalAASamples) |
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 | 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 &vUp) |
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. | |
![]() | |
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 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::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) | |
upoint32_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? | |
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.
auto unravel::camera::classify_aabb | ( | const math::bbox & | bounds | ) | const -> math::volume_query |
Determines if the specified AABB falls within the frustum.
bounds | The AABB to test. |
Definition at line 417 of file camera.cpp.
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.
bounds | The OBB to test. |
t | The transformation to apply to the OBB. |
Definition at line 435 of file camera.cpp.
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.
pixel_tolerance | The pixel tolerance. |
reference_position | The reference position. |
object_transform | The transformation to apply to the object. |
Definition at line 710 of file camera.cpp.
auto unravel::camera::estimate_zoom_factor | ( | const math::plane & | plane | ) | const -> float |
Estimates the zoom factor based on the specified plane.
plane | The reference plane. |
Definition at line 640 of file camera.cpp.
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.
plane | The reference plane. |
maximum_value | The maximum zoom factor value. |
Definition at line 673 of file camera.cpp.
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.
position | The reference position. |
Definition at line 668 of file camera.cpp.
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.
position | The reference position. |
maximum_value | The maximum zoom factor value. |
Definition at line 693 of file camera.cpp.
auto unravel::camera::get_aa_data | ( | ) | const -> const math::vec4& |
Retrieves the anti-aliasing data.
Definition at line 808 of file camera.cpp.
auto unravel::camera::get_aspect_ratio | ( | ) | const -> float |
Retrieves the aspect ratio used to generate the horizontal FOV angle.
Definition at line 183 of file camera.cpp.
auto unravel::camera::get_clipping_volume | ( | ) | const -> const math::frustum& |
Retrieves the frustum representing the space between the camera position and its near plane.
Definition at line 405 of file camera.cpp.
|
static |
Retrieves a camera for one of six cube faces.
face | The index of the cube face. |
transform | The transformation to apply. |
Definition at line 822 of file camera.cpp.
auto unravel::camera::get_far_clip | ( | ) | const -> float |
Retrieves the distance from the camera to the far clip plane.
Definition at line 67 of file camera.cpp.
auto unravel::camera::get_fov | ( | ) | const -> float |
Retrieves the current field of view angle in degrees.
Definition at line 57 of file camera.cpp.
auto unravel::camera::get_frustum | ( | ) | const -> const math::frustum& |
Retrieves the current camera object frustum.
Definition at line 365 of file camera.cpp.
auto unravel::camera::get_local_bounding_box | ( | ) | -> math::bbox |
Retrieves the bounding box of this object.
Definition at line 145 of file camera.cpp.
auto unravel::camera::get_near_clip | ( | ) | const -> float |
Retrieves the distance from the camera to the near clip plane.
Definition at line 62 of file camera.cpp.
auto unravel::camera::get_ortho_size | ( | ) | const -> float |
Retrieves the orthographic size.
Definition at line 72 of file camera.cpp.
auto unravel::camera::get_position | ( | ) | const -> const math::vec3& |
Retrieves the current position of the camera.
Definition at line 346 of file camera.cpp.
auto unravel::camera::get_ppu | ( | ) | const -> float |
Retrieves the pixels per unit (PPU).
Definition at line 19 of file camera.cpp.
auto unravel::camera::get_prev_projection | ( | ) | const -> const math::transform& |
Definition at line 271 of file camera.cpp.
auto unravel::camera::get_prev_view | ( | ) | const -> const math::transform& |
Definition at line 281 of file camera.cpp.
auto unravel::camera::get_prev_view_projection | ( | ) | const -> math::transform |
Retrieves the previous view matrix.
Definition at line 311 of file camera.cpp.
auto unravel::camera::get_prev_view_projection_relative | ( | ) | const -> math::transform |
Definition at line 321 of file camera.cpp.
auto unravel::camera::get_prev_view_relative | ( | ) | const -> const math::transform& |
Definition at line 291 of file camera.cpp.
auto unravel::camera::get_projection | ( | ) | const -> const math::transform& |
Retrieves the current projection matrix.
Definition at line 203 of file camera.cpp.
auto unravel::camera::get_projection_mode | ( | ) | const -> projection_mode |
Retrieves the current projection mode for this camera.
Definition at line 52 of file camera.cpp.
auto unravel::camera::get_view | ( | ) | const -> const math::transform& |
Retrieves the current view matrix.
Definition at line 276 of file camera.cpp.
auto unravel::camera::get_view_inverse | ( | ) | const -> const math::transform& |
Definition at line 296 of file camera.cpp.
auto unravel::camera::get_view_inverse_relative | ( | ) | const -> const math::transform& |
Definition at line 301 of file camera.cpp.
auto unravel::camera::get_view_projection | ( | ) | const -> math::transform |
Retrieves the current view-projection matrix.
Definition at line 306 of file camera.cpp.
auto unravel::camera::get_view_projection_relative | ( | ) | const -> math::transform |
Definition at line 316 of file camera.cpp.
auto unravel::camera::get_view_relative | ( | ) | const -> const math::transform& |
Definition at line 286 of file camera.cpp.
auto unravel::camera::get_viewport_pos | ( | ) | const -> const upoint32_t& |
Retrieves the position of the viewport.
Definition at line 40 of file camera.cpp.
auto unravel::camera::get_viewport_size | ( | ) | const -> const usize32_t& |
Retrieves the size of the viewport.
Definition at line 35 of file camera.cpp.
auto unravel::camera::get_zoom_factor | ( | ) | const -> float |
auto unravel::camera::is_aspect_locked | ( | ) | const -> bool |
Determines if the aspect ratio is currently being updated by the render driver.
Definition at line 188 of file camera.cpp.
auto unravel::camera::is_frustum_locked | ( | ) | const -> bool |
Checks if the frustum is currently locked.
Definition at line 193 of file camera.cpp.
void unravel::camera::lock_frustum | ( | bool | locked | ) |
Locks or unlocks the frustum.
locked | Whether the frustum should be locked. |
Definition at line 198 of file camera.cpp.
void unravel::camera::look_at | ( | const math::vec3 & | eye, |
const math::vec3 & | at ) |
Sets the camera to look at a specified target.
eye | The eye position. |
at | The target position. |
Definition at line 326 of file camera.cpp.
void unravel::camera::look_at | ( | const math::vec3 & | eye, |
const math::vec3 & | at, | ||
const math::vec3 & | vUp ) |
Sets the camera to look at a specified target with an up vector.
eye | The eye position. |
at | The target position. |
vUp | The up vector. |
Definition at line 331 of file camera.cpp.
void unravel::camera::record_current_matrices | ( | ) |
Makes a copy of the current view and projection matrices before they are changed.
Definition at line 724 of file camera.cpp.
void unravel::camera::set_aa_data | ( | const usize32_t & | viewportSize, |
std::uint32_t | currentSubpixelIndex, | ||
std::uint32_t | temporalAASamples ) |
Sets the current jitter value for temporal anti-aliasing.
viewportSize | The size of the viewport. |
currentSubpixelIndex | The current subpixel index. |
temporalAASamples | The number of temporal AA samples. |
Definition at line 732 of file camera.cpp.
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).
aspect | The aspect ratio to set. |
locked | Whether the aspect ratio should be locked. |
Definition at line 165 of file camera.cpp.
void unravel::camera::set_far_clip | ( | float | distance | ) |
Sets the far plane distance.
distance | The distance to the far clipping plane. |
Definition at line 125 of file camera.cpp.
void unravel::camera::set_fov | ( | float | degrees | ) |
Sets the field of view angle of this camera (perspective only).
degrees | The field of view in degrees. |
Definition at line 77 of file camera.cpp.
void unravel::camera::set_near_clip | ( | float | distance | ) |
Sets the near plane distance.
distance | The distance to the near clipping plane. |
Definition at line 105 of file camera.cpp.
void unravel::camera::set_orthographic_size | ( | float | size | ) |
Sets the half of the vertical size of the viewing volume in world units.
size | The size to set. |
Definition at line 45 of file camera.cpp.
void unravel::camera::set_projection_mode | ( | projection_mode | mode | ) |
Sets the current projection mode for this camera (i.e. orthographic or perspective).
mode | The projection mode to set. |
Definition at line 91 of file camera.cpp.
void unravel::camera::set_viewport_pos | ( | const upoint32_t & | viewportPos | ) |
Sets the position of the viewport.
viewportPos | The position of the viewport. |
Definition at line 30 of file camera.cpp.
void unravel::camera::set_viewport_size | ( | const usize32_t & | viewportSize | ) |
Sets the size of the viewport.
viewportSize | The size of the viewport. |
Definition at line 24 of file camera.cpp.
auto unravel::camera::test_aabb | ( | const math::bbox & | bounds | ) | const -> bool |
Tests if the specified AABB is within the frustum.
bounds | The AABB to test. |
Definition at line 426 of file camera.cpp.
auto unravel::camera::test_billboard | ( | float | size, |
const math::transform & | t ) const -> bool |
Definition at line 453 of file camera.cpp.
auto unravel::camera::test_obb | ( | const math::bbox & | bounds, |
const math::transform & | t ) const -> bool |
Tests if the specified OBB is within the frustum.
bounds | The OBB to test. |
t | The transformation to apply to the OBB. |
Definition at line 444 of file camera.cpp.
void unravel::camera::touch | ( | ) |
Marks the camera as modified.
Definition at line 813 of file camera.cpp.
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.
point | The screen position. |
position_out | The output camera space position. |
Definition at line 626 of file camera.cpp.
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.
point | The screen position. |
axis_origin | The origin of the axis. |
align_normal | The alignment normal. |
position_out | The output world space position. |
major_axis_out | The output major axis. |
Definition at line 583 of file camera.cpp.
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.
point | The screen position. |
axis_origin | The origin of the axis. |
position_out | The output world space position. |
major_axis_out | The output major axis. |
Definition at line 575 of file camera.cpp.
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.
point | The screen position. |
rayOriginOut | The output ray origin. |
rayDirectionOut | The output ray direction. |
Definition at line 490 of file camera.cpp.
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.
point | The screen position. |
plane | The plane to intersect. |
position_out | The output world space position. |
clip | Whether to clip the result. |
Definition at line 523 of file camera.cpp.
auto unravel::camera::world_to_viewport | ( | const math::vec3 & | pos | ) | const -> math::vec3 |
Transforms a point from world space into screen space.
pos | The world space position. |
Definition at line 466 of file camera.cpp.
auto unravel::camera::x_unit_axis | ( | ) | const -> math::vec3 |
Retrieves the x-axis unit vector of the camera's local coordinate system.
Definition at line 351 of file camera.cpp.
auto unravel::camera::y_unit_axis | ( | ) | const -> math::vec3 |
Retrieves the y-axis unit vector of the camera's local coordinate system.
Definition at line 355 of file camera.cpp.
auto unravel::camera::z_unit_axis | ( | ) | const -> math::vec3 |
Retrieves the z-axis unit vector of the camera's local coordinate system.
Definition at line 360 of file camera.cpp.
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
mutableprotected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |