#pragma once #include "Camera.h" #include using namespace glm; class Camera3D : public Camera { public: Camera3D( float fov_y, float aspect_ratio, float znear, float zfar, const vec3& position, const vec3& forward = vec3(0.0f, 0.0f, 1.0f), const vec3& up = vec3(0.0f, 1.0f, 0.0f), const vec3& right = vec3(0.0f) // Zero for auto-calculated ); void update_frustum(float fov_y, float aspect_ratio, float znear, float zfar); void update_position(const vec3& position); // Updates the orientation based on three vectors. // If right is equal to zero it is calculated with glm::cross(forward, up). // Then the true up is calculated with glm::cross(right, forward) void update_orientation(const vec3& forward = vec3(0.0f, 0.0f, 1.0f), const vec3& up = vec3(0.0f, 1.0f, 0.0f), const vec3& right = vec3(0.0f)); // Directly sets the forward, up, and right values. void direct_update_orientation(const vec3& forward, const vec3& up, const vec3& right); void translate(const vec3& translation); void rotate(const vec3& axis, float angle); void prerender(); const vec3& get_position() const { return m_position; } vec3 get_forward() const { return vec3(m_forward); } vec3 get_up() const { return vec3(m_up); } vec3 get_right() const { return vec3(m_right); } private: vec3 m_position; vec4 m_forward; vec4 m_up; vec4 m_right; };