39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
class Camera
|
|
{
|
|
private:
|
|
glm::vec3 m_position = { -1.f, 1.f, 1.f };
|
|
glm::vec3 m_front = { 0.f, 0.f, 0.f };
|
|
glm::vec3 m_right = glm::normalize(glm::cross(m_position - m_front, glm::vec3(0.f, 1.f, 0.f)));
|
|
glm::vec3 m_up = glm::normalize(glm::cross(m_position - m_front, m_position - m_right));
|
|
|
|
float m_yaw = -44.977; // atan2(m_position.x, m_position.z) assuming m_position = {-1, 1, 1}
|
|
float m_pitch = 35.264; // asin(m_position.y) assuming m_position = {-1, 1, 1}
|
|
|
|
public:
|
|
// Since all variables are dependent on each other I've decided to
|
|
// disable the setters until I make sure they don't break things
|
|
// glm::vec3& position() { return m_position; }
|
|
// glm::vec3& front() { return m_front; }
|
|
// glm::vec3& up() { return m_up; }
|
|
// glm::vec3& right() { return m_right; }
|
|
//
|
|
// float& yaw() { return m_yaw; }
|
|
// float& pitch() { return m_pitch; }
|
|
|
|
const glm::vec3& position() const { return m_position; }
|
|
const glm::vec3& front() const { return m_front; }
|
|
const glm::vec3& up() const { return m_up; }
|
|
const glm::vec3& right() const { return m_right; }
|
|
|
|
const float& yaw() const { return m_yaw; }
|
|
const float pitch() const { return m_pitch; }
|
|
|
|
|
|
void pan(float dist_x, float dist_y);
|
|
void orbit(float yaw, float pitch);
|
|
void zoom(float dist);
|
|
}; |