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 Frame(const Bounds& bounds);
31 void FramePoint(const glm::vec3& point, float radius = 0.5f);
32
33 [[nodiscard]] ExtractedView BuildView(glm::uvec2 target_extent) const;
34 [[nodiscard]] glm::vec3 GetPosition() const;
35 [[nodiscard]] glm::vec3 GetForward() const;
36 [[nodiscard]] glm::vec3 GetRight() const;
37 [[nodiscard]] glm::vec3 GetUp() const;
38
39 [[nodiscard]] const glm::vec3& GetPivot() const noexcept
40 {
41 return pivot_;
42 }
43 [[nodiscard]] float GetDistance() const noexcept
44 {
45 return distance_;
46 }
47 [[nodiscard]] float GetYawDegrees() const noexcept
48 {
49 return yaw_degrees_;
50 }
51 [[nodiscard]] float GetPitchDegrees() const noexcept
52 {
53 return pitch_degrees_;
54 }
55 [[nodiscard]] float GetFieldOfViewDegrees() const noexcept
56 {
57 return field_of_view_degrees_;
58 }
59 [[nodiscard]] float GetNearPlane() const noexcept
60 {
61 return near_plane_;
62 }
63 [[nodiscard]] float GetFarPlane() const noexcept
64 {
65 return far_plane_;
66 }
67
68private:
69 glm::vec3 pivot_ = glm::vec3(0.0f);
70 float distance_ = 6.0f;
71 float yaw_degrees_ = 35.0f;
72 float pitch_degrees_ = -25.0f;
73 float field_of_view_degrees_ = 45.0f;
74 float near_plane_ = 0.1f;
75 float far_plane_ = 1000.0f;
76};
77} // namespace pixelbullet
Definition view.h:8
Definition orbit_camera.h:13