Go to the documentation of this file. 1 #ifndef OGLPLUS_CAMERA_HPP
9 #define OGLPLUS_CAMERA_HPP
11 #include "math/interpolate.hpp"
13 #include "math/primitives.hpp"
14 #include "math/sign.hpp"
15 #include "math/vector.hpp"
19 namespace eagine::oglp {
51 _orbit_min =
orbit.value();
57 _orbit_max =
orbit.value();
69 auto orbit() const noexcept ->
float {
70 return smooth_lerp(_orbit_min, _orbit_max, _orbit_factor);
109 auto perspective_matrix_ctr(
float aspect)
const noexcept {
110 return matrix_perspective::y(_fov, aspect, _near, _far);
115 return perspective_matrix_ctr(aspect)();
118 auto transform_matrix_ctr() const noexcept {
124 return transform_matrix_ctr()();
128 auto matrix(
float aspect)
const noexcept {
129 return perspective_matrix_ctr(aspect) * transform_matrix_ctr();
137 auto pointer_ray(
float ndcx,
float ndcy,
float aspect)
const noexcept
140 auto grab_sphere_radius() const noexcept ->
float;
141 auto grab_sphere() const noexcept ->
sphere;
151 radians_t<float> _turns{};
152 radians_t<float> _pitch{};
154 float _orbit_min{1.5F};
155 float _orbit_max{5.5F};
156 float _orbit_factor = 0.50F;
161 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
162 #include <oglplus/camera.inl>
auto set_orbit_max(valid_if_positive< float > orbit) noexcept -> auto &
Set maximal orbit value.
Definition: camera.hpp:56
auto perspective_matrix(float aspect) const noexcept
Returns the perspective matrix for the given aspect ratio.
Definition: camera.hpp:114
auto transform_matrix() const noexcept
Returns the camera transformation matrix.
Definition: camera.hpp:123
Basic template for spheres in N-dimensional space.
Definition: primitives.hpp:122
auto set_target(vec3 target) noexcept -> auto &
Sets the target position.
Definition: camera.hpp:26
auto target_to_camera_direction() const noexcept -> vec3
Returns the target-to-camera direction vector.
Primary template for conditionally valid values.
Definition: decl.hpp:49
static auto smooth_lerp(const T &a, const T &b, C coef)
Linear interpolation with coef transformed by sine_sigmoid01.
Definition: interpolate.hpp:42
auto set_far(valid_if_positive< float > dist) noexcept -> auto &
Sets the distance of the far plane.
Definition: camera.hpp:44
auto target() const noexcept -> vec3
Returns the target position.
Definition: camera.hpp:89
Class representing a camera orbiting around its target.
Definition: camera.hpp:23
auto target_plane_point(float ndcx, float ndcy, float aspect) const noexcept -> optionally_valid< vec3 >
Returns the 3D position of a point (in NDC) on the target plane.
auto position() const noexcept -> vec3
Returns the position of the camera.
Definition: camera.hpp:105
auto set_fov(radians_t< float > angle) noexcept -> auto &
Sets the y-axis FOV angle.
Definition: camera.hpp:32
auto camera_to_target_direction() const noexcept -> vec3
Returns the camera-to-target direction vector.
Definition: camera.hpp:99
auto pointer_ray(float ndcx, float ndcy, float aspect) const noexcept -> optionally_valid< line >
Returns a ray from the camera through a point on the target plane.
auto set_orbit_min(valid_if_positive< float > orbit) noexcept -> auto &
Set minimal orbit value.
Definition: camera.hpp:50
auto elevation() const noexcept -> radians_t< float >
Returns the elevation angle (latitude).
Definition: camera.hpp:83
auto fov() const noexcept -> radians_t< float >
Returns the y-axis FOV angle.
Definition: camera.hpp:62
auto azimuth() const noexcept -> radians_t< float >
Returns the azimuth angle (longitude).
Definition: camera.hpp:76
tvec< gl_types::float_type, 3 > vec3
Alias for a 3D vector type.
Definition: vector.hpp:32
auto matrix(float aspect) const noexcept
Returns the camera matrix (perspective * projection).
Definition: camera.hpp:128
auto orbit() const noexcept -> float
Returns the orbit altitude value.
Definition: camera.hpp:69
auto set_near(valid_if_positive< float > dist) noexcept -> auto &
Sets the distance of the near plane.
Definition: camera.hpp:38
Value of type T with a specified unit or tag type U.
Definition: tagged_quantity.hpp:27
static constexpr auto right_angle_() noexcept
Creates a tagged quantity a right angle value.
Definition: quantities.hpp:71
convertible_matrix_constructor< orbiting_y_up< matrix< T, 4, 4, true, V > >> matrix_orbiting_y_up
Alias for constructor of orbiting matrix used for camera transformations.
Definition: matrix_orbiting.hpp:112