15#ifndef CSCI441_CAMERA_HPP
16#define CSCI441_CAMERA_HPP
18#ifdef CSCI441_USE_GLEW
24#include <glm/mat4x4.hpp>
25#include <glm/vec3.hpp>
26#include <glm/gtc/constants.hpp>
27#include <glm/gtc/matrix_transform.hpp>
57 [[maybe_unused]]
virtual void moveForward(GLfloat movementFactor) = 0;
63 [[maybe_unused]]
virtual void moveBackward(GLfloat movementFactor) = 0;
75 [[maybe_unused]] [[maybe_unused]]
virtual void rotate(GLfloat dTheta, GLfloat dPhi);
206 void _clampCameraPhi();
211 mProjectionMatrix( glm::mat4(1.0f) ),
212 mViewMatrix( glm::mat4(1.0f) ),
213 mCameraPosition( glm::vec3(0.0f, 0.0f, 0.0f ) ),
214 mCameraDirection( glm::vec3(0.0f, 0.0f, -1.0f ) ),
215 mCameraLookAtPoint( glm::vec3(0.0f, 0.0f, -1.0f ) ),
216 mCameraUpVector( glm::vec3(0.0f, 1.0f, 0.0f ) ),
217 mCameraTheta( 0.0f ),
218 mCameraPhi( glm::pi<float>() / 2.0f ),
219 mCameraRadius( 1.0f ) {
224 mCameraTheta += dTheta;
227 recomputeOrientation();
230inline void CSCI441::Camera::_clampCameraPhi() {
231 if(mCameraPhi <= 0.0f) mCameraPhi = 0.0f + 0.001f;
232 if(mCameraPhi >= glm::pi<float>()) mCameraPhi = glm::pi<float>() - 0.001f;
Abstract Class to represent a synthetic camera. The following methods must be overridden:
Definition: Camera.hpp:37
GLfloat mCameraPhi
spherical angle for pitch direction in radians
Definition: Camera.hpp:195
virtual void setRadius(const GLfloat r) final
sets the camera's radius in world space
Definition: Camera.hpp:152
virtual GLfloat getPhi() const final
returns the current phi value in radians
Definition: Camera.hpp:116
virtual void setTheta(const GLfloat t) final
sets the camera's theta angle in radians
Definition: Camera.hpp:142
Camera()
create a default camera at the origin, looking down the negative Z axis oriented with the world coord...
Definition: Camera.hpp:210
virtual glm::vec3 getLookAtPoint() const final
returns the current lookAt point in world space
Definition: Camera.hpp:101
virtual void moveBackward(GLfloat movementFactor)=0
steps backward along the camera's view
virtual void computeViewMatrix() final
creates the View Matrix based on the position, lookAt point, and up vector
Definition: Camera.hpp:80
virtual glm::mat4 getViewMatrix() const final
returns the current view matrix for the associated camera
Definition: Camera.hpp:91
virtual void recomputeOrientation()=0
Uses theta, phi, & radius to update the camera's view matrix parameters. The camera orientation is co...
virtual void setPosition(const glm::vec3 pos) final
sets the camera's position in world space
Definition: Camera.hpp:127
GLfloat mCameraTheta
spherical angle for yaw direction in radians
Definition: Camera.hpp:191
virtual GLfloat getTheta() const final
returns the current theta value in radians
Definition: Camera.hpp:111
virtual glm::vec3 getPosition() const final
returns the current camera position in world space
Definition: Camera.hpp:96
glm::mat4 mProjectionMatrix
stores the Projection Matrix
Definition: Camera.hpp:164
glm::vec3 mCameraPosition
the cartesian position in world space of the camera
Definition: Camera.hpp:174
virtual glm::vec3 getUpVector() const final
returns the current up vector in world space
Definition: Camera.hpp:106
virtual ~Camera()=default
properly destroy concrete children
glm::vec3 mCameraDirection
the cartesian direction the camera is facing in world space
Definition: Camera.hpp:178
glm::mat4 mViewMatrix
stores the View Matrix corresponding to the inverse of the Camera's Matrix
Definition: Camera.hpp:169
virtual void moveForward(GLfloat movementFactor)=0
steps forward along the camera's view
virtual void setLookAtPoint(const glm::vec3 lookAt) final
sets the camera's lookAt point in world space
Definition: Camera.hpp:132
glm::vec3 mCameraLookAtPoint
the world space point in front of the camera
Definition: Camera.hpp:182
virtual glm::mat4 getProjectionMatrix() const final
returns the current projection matrix for the associated camera
Definition: Camera.hpp:86
virtual void setPhi(const GLfloat p) final
sets the camera's phi angle in radians
Definition: Camera.hpp:147
virtual void setUpVector(const glm::vec3 up) final
sets the camera's up vector in world space
Definition: Camera.hpp:137
glm::vec3 mCameraUpVector
the up vector of the camera specified in world space
Definition: Camera.hpp:186
GLfloat mCameraRadius
spherical magnitude for direction in world space
Definition: Camera.hpp:199
virtual void rotate(GLfloat dTheta, GLfloat dPhi)
rotates the camera's POV by adding to theta & phi then ensuring phi stays within the (0,...
Definition: Camera.hpp:223
GLfloat getRadius() const
returns the current radius in world space
Definition: Camera.hpp:121
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17