opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
polar_perspective_camera.h
Go to the documentation of this file.
1#pragma once
2
7
8namespace osc { struct AABB; }
9namespace osc { class Rect; }
10
11namespace osc
12{
13 // a camera that focuses on and swivels around a focal point (e.g. for 3D model viewers)
15
17
18 // reset the camera to its initial state
19 void reset();
20
21 // note: relative deltas here are relative to whatever viewport the camera
22 // is handling.
23 //
24 // e.g. moving a mouse 400px in X in a viewport that is 800px wide should
25 // have a delta.x of 0.5f
26
27 // pan: pan along the current view plane
29
30 // drag: spin the view around the origin, such that the distance between
31 // the camera and the origin remains constant
33
34 // autoscale znear and zfar based on the camera's distance from what it's looking at
35 //
36 // important for looking at tiny/large scenes. znear and zfar dictates
37 // both the culling planes of the camera *and* rescales the Z values of elements
38 // in the scene. If the znear-to-zfar range is too large then Z-fighting will happen
39 // and the scene will look wrong.
41
44
45 // uses this camera's transform to project a world space point
46 // onto the given viewport rectangle.
48
50
51 // converts a `pos` (top-left) in the output `dimensions` into a `Ray` in world space by unprojection
53
54 // Returns the height of the view frustum in world units at a given depth from
55 // the camera origin (also in world units).
56 float frustum_height_at_depth(float depth) const;
57
58 friend bool operator==(const PolarPerspectiveCamera&, const PolarPerspectiveCamera&) = default;
59
60 float radius;
65 float znear;
66 float zfar;
67 };
68
72 void focus_along_axis(PolarPerspectiveCamera&, size_t, bool negate = false);
83}
Definition angle.h:25
Definition rect.h:17
Definition custom_decoration_generator.h:5
void focus_along_minus_x(PolarPerspectiveCamera &)
void focus_along_y(PolarPerspectiveCamera &)
void auto_focus(PolarPerspectiveCamera &, const AABB &element_aabb, float aspect_ratio=1.0f)
void focus_along_minus_z(PolarPerspectiveCamera &)
void zoom_in(PolarPerspectiveCamera &)
PolarPerspectiveCamera create_camera_with_radius(float)
PolarPerspectiveCamera create_camera_focused_on(const AABB &)
void focus_along_axis(PolarPerspectiveCamera &, size_t, bool negate=false)
void focus_along_minus_y(PolarPerspectiveCamera &)
constexpr U to(T &&value)
Definition conversion.h:56
void focus_along_z(PolarPerspectiveCamera &)
void zoom_out(PolarPerspectiveCamera &)
void focus_along_x(PolarPerspectiveCamera &)
void reset(PolarPerspectiveCamera &)
Vector3 recommended_light_direction(const PolarPerspectiveCamera &)
Definition aabb.h:14
Definition polar_perspective_camera.h:14
Matrix4x4 projection_matrix(float aspect_ratio) const
Radians phi
Definition polar_perspective_camera.h:62
Radians vertical_field_of_view
Definition polar_perspective_camera.h:64
float zfar
Definition polar_perspective_camera.h:66
Matrix4x4 view_matrix() const
Vector2 project_onto_viewport(const Vector3 &world_space_position, const Rect &viewport_rect) const
float radius
Definition polar_perspective_camera.h:60
void rescale_znear_and_zfar_based_on_radius()
Ray unproject_topleft_position_to_world_ray(Vector2 pos, Vector2 dimensions) const
void drag(Vector2 mouse_delta)
float znear
Definition polar_perspective_camera.h:65
void pan(float aspect_ratio, Vector2 mouse_delta)
Vector3 focus_point
Definition polar_perspective_camera.h:63
float frustum_height_at_depth(float depth) const
Radians theta
Definition polar_perspective_camera.h:61
friend bool operator==(const PolarPerspectiveCamera &, const PolarPerspectiveCamera &)=default
Definition ray.h:13