PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
orbit_camera.h
1#pragma once
2
3#include "pixelbullet/scene/view.h"
4
5#include <glm/glm.hpp>
6
7namespace pixelbullet
8{
9class OrbitCamera
10{
11public:
12 struct Bounds
13 {
14 glm::vec3 min = glm::vec3(0.0f);
15 glm::vec3 max = glm::vec3(0.0f);
16 bool valid = false;
17
18 void Include(const glm::vec3& point);
19 [[nodiscard]] glm::vec3 GetCenter() const;
20 [[nodiscard]] glm::vec3 GetExtents() const;
21 };
22
23 OrbitCamera();
24
25 void Reset();
26 void SetLookAt(const glm::vec3& position, const glm::vec3& pivot, float field_of_view_degrees, float near_plane, float far_plane);
27 void Orbit(const glm::vec2& delta);
28 void Pan(const glm::vec2& delta, const glm::vec2& viewport_size);
29 void Dolly(float delta);
30 void Translate(const glm::vec3& delta);
31 void Frame(const Bounds& bounds);
32 void FramePoint(const glm::vec3& point, float radius = 0.5f);
33 void FramePointClose(const glm::vec3& point, float radius = 0.08f);
34
35 [[nodiscard]] ExtractedView BuildView(glm::uvec2 target_extent) const;
36 [[nodiscard]] glm::vec3 GetPosition() const;
37 [[nodiscard]] glm::vec3 GetForward() const;
38 [[nodiscard]] glm::vec3 GetRight() const;
39 [[nodiscard]] glm::vec3 GetUp() const;
40
41 [[nodiscard]] const glm::vec3& GetPivot() const noexcept
42 {
43 return pivot_;
44 }
45 [[nodiscard]] float GetDistance() const noexcept
46 {
47 return distance_;
48 }
49 [[nodiscard]] float GetYawDegrees() const noexcept
50 {
51 return yaw_degrees_;
52 }
53 [[nodiscard]] float GetPitchDegrees() const noexcept
54 {
55 return pitch_degrees_;
56 }
57 [[nodiscard]] float GetFieldOfViewDegrees() const noexcept
58 {
59 return field_of_view_degrees_;
60 }
61 [[nodiscard]] float GetNearPlane() const noexcept
62 {
63 return near_plane_;
64 }
65 [[nodiscard]] float GetFarPlane() const noexcept
66 {
67 return far_plane_;
68 }
69
70private:
71 glm::vec3 pivot_ = glm::vec3(0.0f);
72 float distance_ = 6.0f;
73 float yaw_degrees_ = 35.0f;
74 float pitch_degrees_ = -25.0f;
75 float field_of_view_degrees_ = 45.0f;
76 float near_plane_ = 0.1f;
77 float far_plane_ = 1000.0f;
78};
79} // namespace pixelbullet
Definition view.h:8
Definition orbit_camera.h:13