Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::OrthographicCameraController Class Reference

#include <OrthographicCameraController.h>

Public Member Functions

 OrthographicCameraController (float aspectRatio, bool rotation=false)
void OnUpdate (Timestep ts)
void OnEvent (Event &e)
void OnResize (float width, float height)
OrthographicCameraGetCamera ()
const OrthographicCameraGetCamera () const
OrthographicCameraBounds GetBounds () const
glm::vec3 GetPosition () const
void SetPosition (float x, float y)
void SetMoveSpeed (float speed)
float GetMoveSpeed () const
void SetRotation (float rotation)
float GetRotation () const
void SetRotationSpeed (float speed)
float GetRotationSpeed () const
float GetAspectRatio () const
void SetAspectRatio (float aspectRatio)
bool CanRotate () const
void SetCanRotate (bool canRotate)
void SetZoomLevel (float level)
float GetZoomLevel () const
void OnImGuiRender ()
 TODO: move to an editor component that can be attached to any system (EditorAbstractionComp).

Private Member Functions

bool OnMouseScrolled (MouseScrolledEvent &e)
bool OnWindowResized (WindowResizeEvent &e)
void UpdateCameraBounds ()
void OnUpdateBounds ()
void CalculateView ()

Private Attributes

float m_AspectRatio
float m_ZoomLevel = 1.0f
OrthographicCamera camera
OrthographicCameraBounds m_Bounds
bool m_Rotation = true
glm::vec3 m_CameraPosition = { 0.0f, 0.0f, 0.0f }
float m_CameraRotation = 0.0f
float m_CameraMoveSpeed = 5.0f
float m_CameraRotationSpeed = 180.0f

Constructor & Destructor Documentation

◆ OrthographicCameraController()

Vesper::OrthographicCameraController::OrthographicCameraController ( float aspectRatio,
bool rotation = false )
14 : m_AspectRatio(aspectRatio), m_Rotation(rotation),
17 {
18
19 }
bool m_Rotation
Definition OrthographicCameraController.h:73
float m_ZoomLevel
Definition OrthographicCameraController.h:69
OrthographicCameraBounds m_Bounds
Definition OrthographicCameraController.h:71
float m_AspectRatio
Definition OrthographicCameraController.h:68
OrthographicCamera camera
Definition OrthographicCameraController.h:70

References m_AspectRatio, m_Bounds, m_Rotation, m_ZoomLevel, and OrthographicCameraController().

Referenced by OrthographicCameraController().

Member Function Documentation

◆ CalculateView()

void Vesper::OrthographicCameraController::CalculateView ( )
private
96 {
98 camera.SetProjection(m_Bounds.Left, m_Bounds.Right, m_Bounds.Bottom, m_Bounds.Top);
99 }
void UpdateCameraBounds()
Definition OrthographicCameraController.cpp:81

References UpdateCameraBounds().

Referenced by OnMouseScrolled(), OnResize(), SetAspectRatio(), and SetZoomLevel().

◆ CanRotate()

bool Vesper::OrthographicCameraController::CanRotate ( ) const
inline
53{ return m_Rotation; }

References m_Rotation.

Referenced by OnImGuiRender().

◆ GetAspectRatio()

float Vesper::OrthographicCameraController::GetAspectRatio ( ) const
124 {
125 return m_AspectRatio;
126 }

References m_AspectRatio.

◆ GetBounds()

OrthographicCameraBounds Vesper::OrthographicCameraController::GetBounds ( ) const
inline
36{ return m_Bounds; }

References m_Bounds.

◆ GetCamera() [1/2]

OrthographicCamera & Vesper::OrthographicCameraController::GetCamera ( )
inline
34{ return camera; }

◆ GetCamera() [2/2]

const OrthographicCamera & Vesper::OrthographicCameraController::GetCamera ( ) const
inline
35{ return camera; }

◆ GetMoveSpeed()

float Vesper::OrthographicCameraController::GetMoveSpeed ( ) const
inline
42{ return m_CameraMoveSpeed; }
float m_CameraMoveSpeed
Definition OrthographicCameraController.h:76

References m_CameraMoveSpeed.

Referenced by OnImGuiRender().

◆ GetPosition()

glm::vec3 Vesper::OrthographicCameraController::GetPosition ( ) const
inline
38{ return m_CameraPosition; }
glm::vec3 m_CameraPosition
Definition OrthographicCameraController.h:74

◆ GetRotation()

float Vesper::OrthographicCameraController::GetRotation ( ) const
inline
45{ return m_CameraRotation; }
float m_CameraRotation
Definition OrthographicCameraController.h:75

References m_CameraRotation.

Referenced by OnImGuiRender().

◆ GetRotationSpeed()

float Vesper::OrthographicCameraController::GetRotationSpeed ( ) const
inline
48{ return m_CameraRotationSpeed; }
float m_CameraRotationSpeed
Definition OrthographicCameraController.h:76

References m_CameraRotationSpeed.

Referenced by OnImGuiRender().

◆ GetZoomLevel()

float Vesper::OrthographicCameraController::GetZoomLevel ( ) const
inline
57{ return m_ZoomLevel; }

References m_ZoomLevel.

◆ OnEvent()

void Vesper::OrthographicCameraController::OnEvent ( Event & e)
48 {
50 EventDispatcher dispatcher(e);
51 dispatcher.Dispatch<MouseScrolledEvent>(VZ_BIND_EVENT_FN(OrthographicCameraController::OnMouseScrolled));
52 dispatcher.Dispatch<WindowResizeEvent>(VZ_BIND_EVENT_FN(OrthographicCameraController::OnWindowResized));
53
54 }
#define VZ_BIND_EVENT_FN(fn)
Binds a member function as an event handler.
Definition Defines_Macros.h:17
#define VZ_PROFILE_FUNCTION()
Definition Instrumentor.h:240
bool OnMouseScrolled(MouseScrolledEvent &e)
Definition OrthographicCameraController.cpp:65
bool OnWindowResized(WindowResizeEvent &e)
Definition OrthographicCameraController.cpp:74

References Vesper::EventDispatcher::EventDispatcher(), OnMouseScrolled(), and OnWindowResized().

◆ OnImGuiRender()

void Vesper::OrthographicCameraController::OnImGuiRender ( )

TODO: move to an editor component that can be attached to any system (EditorAbstractionComp).

137 {
138 //ImGui::Begin("Settings");
139
140 static float camPos[3] = { GetPosition().x, GetPosition().y, GetPosition().z };
141 if (ImGui::DragFloat3("Cam Pos", camPos, 0.1f)) {
142 SetPosition(camPos[0], camPos[1]);
143 }
144 static float camMoveSpeed = GetMoveSpeed();
145 if (ImGui::DragFloat("Cam Speed", &camMoveSpeed, 0.1f)) {
146 SetMoveSpeed(camMoveSpeed);
147 }
148 ImGui::Separator();
149 static bool rotate = CanRotate();
150 if (ImGui::Checkbox("Rotate?", &rotate)) {
151 SetCanRotate(rotate);
152 }
153 ImGui::Separator();
154 static float camRot = GetRotation();
155 if (ImGui::DragFloat("Cam Rotation", &camRot, 0.1f)) {
156 SetRotation(camRot);
157 }
158 static float camRotSpeed = GetRotationSpeed();
159 if (ImGui::DragFloat("Cam Rot Speed", &camRotSpeed, 1.0f)) {
160 SetRotationSpeed(camRotSpeed);
161 }
162 //ImGui::End();
163
164 }
void SetRotationSpeed(float speed)
Definition OrthographicCameraController.cpp:118
void SetMoveSpeed(float speed)
Definition OrthographicCameraController.cpp:107
void SetCanRotate(bool canRotate)
Definition OrthographicCameraController.h:54
bool CanRotate() const
Definition OrthographicCameraController.h:53
float GetRotationSpeed() const
Definition OrthographicCameraController.h:48
float GetMoveSpeed() const
Definition OrthographicCameraController.h:42
glm::vec3 GetPosition() const
Definition OrthographicCameraController.h:38
void SetPosition(float x, float y)
Definition OrthographicCameraController.cpp:101
float GetRotation() const
Definition OrthographicCameraController.h:45
void SetRotation(float rotation)
Definition OrthographicCameraController.cpp:112

References CanRotate(), GetMoveSpeed(), GetRotation(), GetRotationSpeed(), SetCanRotate(), SetMoveSpeed(), SetPosition(), SetRotation(), and SetRotationSpeed().

◆ OnMouseScrolled()

bool Vesper::OrthographicCameraController::OnMouseScrolled ( MouseScrolledEvent & e)
private
66 {
68 m_ZoomLevel -= e.GetYOffset() * 0.25f;
69 m_ZoomLevel = std::max(m_ZoomLevel, 0.25f);
71 return false;
72 }
void CalculateView()
Definition OrthographicCameraController.cpp:95

References CalculateView(), Vesper::MouseScrolledEvent::GetYOffset(), and m_ZoomLevel.

Referenced by OnEvent().

◆ OnResize()

void Vesper::OrthographicCameraController::OnResize ( float width,
float height )
57 {
59 m_AspectRatio = width / height;
61
62 }

References CalculateView(), and m_AspectRatio.

Referenced by OnWindowResized().

◆ OnUpdate()

void Vesper::OrthographicCameraController::OnUpdate ( Timestep ts)
22 {
24
29
34
35 if (m_Rotation)
36 {
41
42 camera.SetRotation(m_CameraRotation);
43 }
44 camera.SetPosition(m_CameraPosition);
45 }
static bool IsKeyPressed(int keycode)
Checks if the specified key is currently pressed.
Definition WindowsInput.cpp:9
@ Q
Definition KeyCodes.h:54
@ A
Definition KeyCodes.h:38
@ D
Definition KeyCodes.h:41
@ W
Definition KeyCodes.h:60
@ E
Definition KeyCodes.h:42
@ S
Definition KeyCodes.h:56

References Vesper::Key::E, Vesper::Input::IsKeyPressed(), m_CameraRotation, m_CameraRotationSpeed, m_Rotation, and Vesper::Key::Q.

◆ OnUpdateBounds()

void Vesper::OrthographicCameraController::OnUpdateBounds ( )
private
91 {
92 // Nothing for now
93 }

Referenced by UpdateCameraBounds().

◆ OnWindowResized()

bool Vesper::OrthographicCameraController::OnWindowResized ( WindowResizeEvent & e)
private
75 {
77 OnResize((float)e.GetWidth(), (float)e.GetHeight());
78 return false;
79 }
void OnResize(float width, float height)
Definition OrthographicCameraController.cpp:56

References Vesper::WindowResizeEvent::GetHeight(), Vesper::WindowResizeEvent::GetWidth(), and OnResize().

Referenced by OnEvent().

◆ SetAspectRatio()

void Vesper::OrthographicCameraController::SetAspectRatio ( float aspectRatio)
129 {
130 m_AspectRatio = aspectRatio;
132 }

References CalculateView(), and m_AspectRatio.

◆ SetCanRotate()

void Vesper::OrthographicCameraController::SetCanRotate ( bool canRotate)
inline
54{ m_Rotation = canRotate; }

References m_Rotation.

Referenced by OnImGuiRender().

◆ SetMoveSpeed()

void Vesper::OrthographicCameraController::SetMoveSpeed ( float speed)
108 {
109 m_CameraMoveSpeed = speed;
110 }

References m_CameraMoveSpeed.

Referenced by OnImGuiRender().

◆ SetPosition()

void Vesper::OrthographicCameraController::SetPosition ( float x,
float y )
102 {
103 m_CameraPosition = { x, y, 0.0f };
104 camera.SetPosition(m_CameraPosition);
105 }

Referenced by OnImGuiRender().

◆ SetRotation()

void Vesper::OrthographicCameraController::SetRotation ( float rotation)
113 {
114 m_CameraRotation = rotation;
115 camera.SetRotation(m_CameraRotation);
116 }

References m_CameraRotation.

Referenced by OnImGuiRender().

◆ SetRotationSpeed()

void Vesper::OrthographicCameraController::SetRotationSpeed ( float speed)
119 {
120 m_CameraRotationSpeed = speed;
121 }

References m_CameraRotationSpeed.

Referenced by OnImGuiRender().

◆ SetZoomLevel()

void Vesper::OrthographicCameraController::SetZoomLevel ( float level)
inline
56{ m_ZoomLevel = level; CalculateView(); }

References CalculateView(), and m_ZoomLevel.

◆ UpdateCameraBounds()

void Vesper::OrthographicCameraController::UpdateCameraBounds ( )
private

Member Data Documentation

◆ camera

OrthographicCamera Vesper::OrthographicCameraController::camera
private

◆ m_AspectRatio

float Vesper::OrthographicCameraController::m_AspectRatio
private

◆ m_Bounds

OrthographicCameraBounds Vesper::OrthographicCameraController::m_Bounds
private

◆ m_CameraMoveSpeed

float Vesper::OrthographicCameraController::m_CameraMoveSpeed = 5.0f
private

Referenced by GetMoveSpeed(), and SetMoveSpeed().

◆ m_CameraPosition

glm::vec3 Vesper::OrthographicCameraController::m_CameraPosition = { 0.0f, 0.0f, 0.0f }
private
74{ 0.0f, 0.0f, 0.0f };

◆ m_CameraRotation

float Vesper::OrthographicCameraController::m_CameraRotation = 0.0f
private

Referenced by GetRotation(), OnUpdate(), and SetRotation().

◆ m_CameraRotationSpeed

float Vesper::OrthographicCameraController::m_CameraRotationSpeed = 180.0f
private

◆ m_Rotation

bool Vesper::OrthographicCameraController::m_Rotation = true
private

◆ m_ZoomLevel

float Vesper::OrthographicCameraController::m_ZoomLevel = 1.0f
private

The documentation for this class was generated from the following files: