20 #ifndef ANTKEEPER_SCENE_CAMERA_HPP
21 #define ANTKEEPER_SCENE_CAMERA_HPP
102 void set_orthographic(
float clip_left,
float clip_right,
float clip_bottom,
float clip_top,
float clip_near,
float clip_far);
118 m_compositor = compositor;
128 m_composite_index = index;
148 return m_composite_index;
159 return m_orthographic;
177 return m_clip_bottom;
201 return m_vertical_fov;
207 return m_aspect_ratio;
213 return m_exposure_value;
219 return m_exposure_normalization;
243 return m_inv_projection;
249 return m_view_projection;
255 return m_inv_view_projection;
273 return m_view_frustum;
277 void transformed()
override;
278 void update_frustum();
281 int m_composite_index{0};
283 bool m_orthographic{
true};
285 float m_clip_left{-1.0f};
286 float m_clip_right{1.0f};
287 float m_clip_bottom{-1.0f};
288 float m_clip_top{1.0f};
289 float m_clip_near{-1.0f};
290 float m_clip_far{1.0f};
291 float m_vertical_fov{math::half_pi<float>};
292 float m_aspect_ratio{1.0f};
293 float m_exposure_value{0.0f};
294 float m_exposure_normalization{1.0f};
constexpr const math::fmat4 & get_projection() const noexcept
Returns the camera's projection matrix.
constexpr const math::fvec3 & get_up() const noexcept
Returns the camera's up vector.
constexpr const aabb_type & get_bounds() const noexcept override
Returns the bounds of the object.
constexpr float get_clip_right() const noexcept
Returns the signed distance to the camera's right clipping plane.
constexpr float get_exposure_value() const noexcept
Returns the camera's ISO 100 exposure value.
constexpr const math::fmat4 & get_view() const noexcept
Returns the camera's view matrix.
constexpr bool is_orthographic() const noexcept
Returns true if the camera uses an orthographic projection matrix, false otherwise.
constexpr float get_aspect_ratio() const noexcept
Returns the camera's aspect ratio.
constexpr render::compositor * get_compositor() noexcept
Returns the camera's compositor.
void set_aspect_ratio(float aspect_ratio)
Sets the camera's aspect ratio.
constexpr const math::fmat4 & get_view_projection() const noexcept
Returns the camera's view-projection matrix.
constexpr const math::fvec3 & get_forward() const noexcept
Returns the camera's forward vector.
constexpr float get_clip_top() const noexcept
Returns the signed distance to the camera's top clipping plane.
void set_vertical_fov(float vertical_fov)
Sets the camera's vertical field of view.
constexpr int get_composite_index() const noexcept
Returns the composite index of the camera.
math::fvec3 project(const math::fvec3 &object, const math::fvec4 &viewport) const
Maps object coordinates to window coordinates.
math::fvec3 unproject(const math::fvec3 &window, const math::fvec4 &viewport) const
Maps window coordinates to object coordinates.
void set_orthographic(float clip_left, float clip_right, float clip_bottom, float clip_top, float clip_near, float clip_far)
Sets the camera's projection matrix using orthographic projection.
geom::ray< float, 3 > pick(const math::fvec2 &ndc) const
Constructs a picking ray from normalized device coordinates (NDC).
constexpr float get_clip_near() const noexcept
Returns the signed distance to the camera's near clipping plane.
constexpr const math::fmat4 & get_inv_view_projection() const noexcept
Returns the inverse of the camera's view-projection matrix.
constexpr float get_exposure_normalization() const noexcept
Returns the camera's exposure normalization factor.
constexpr float get_vertical_fov() const noexcept
Returns the camera's vertical field of view, in radians.
constexpr const math::fmat4 & get_inv_view() const noexcept
Returns the inverse of the camera's view matrix.
constexpr const math::fmat4 & get_inv_projection() const noexcept
Returns the inverse of the camera's projection matrix.
constexpr float get_clip_left() const noexcept
Returns the signed distance to the camera's left clipping plane.
constexpr const view_frustum_type & get_view_frustum() const noexcept
Returns the camera's view frustum.
void set_exposure_value(float ev100)
Sets the camera's ISO 100 exposure value.
void set_compositor(render::compositor *compositor) noexcept
Sets the camera's compositor.
geom::view_frustum< float > view_frustum_type
Camera view frustum type.
constexpr float get_clip_far() const noexcept
Returns the signed distance to the camera's far clipping plane.
constexpr float get_clip_bottom() const noexcept
Returns the signed distance to the camera's bottom clipping plane.
void set_perspective(float vertical_fov, float aspect_ratio, float near, float far=std::numeric_limits< float >::infinity())
Sets the camera's projection matrix using perspective projection.
void set_composite_index(int index) noexcept
Sets the composite index of the camera.
constexpr const render::compositor * get_compositor() const noexcept
Returns the camera's compositor.
geom::box< float > aabb_type
Abstract base class for lights, cameras, model instances, and other scene objects.
T vertical_fov(T h, T r)
Calculates a vertical FoV given a horizontal FoV and aspect ratio.
n-dimensional axis-aligned rectangle.
Half of a line proceeding from an initial point.
n by m column-major matrix.
static constexpr matrix identity() noexcept
Returns an identity matrix, with ones on the main diagonal and zeros elsewhere.