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);
226 void _clampCameraPhi();
231 mProjectionMatrix( glm::mat4(1.0f) ),
232 mViewMatrix( glm::mat4(1.0f) ),
233 mCameraPosition( glm::vec3(0.0f, 0.0f, 0.0f ) ),
234 mCameraDirection( glm::vec3(0.0f, 0.0f, -1.0f ) ),
235 mCameraLookAtPoint( glm::vec3(0.0f, 0.0f, -1.0f ) ),
236 mCameraUpVector( glm::vec3(0.0f, 1.0f, 0.0f ) ),
237 mCameraTheta( 0.0f ),
238 mCameraPhi( glm::pi<float>() / 2.0f ),
239 mCameraRadius( 1.0f ) {
244 mCameraTheta += dTheta;
247 recomputeOrientation();
250inline void CSCI441::Camera::_clampCameraPhi() {
251 if(mCameraPhi <= 0.0f) mCameraPhi = 0.0f + 0.001f;
252 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
virtual GLfloat getRadius() const final
returns the current radius in world space
Definition: Camera.hpp:121
GLfloat mCameraPhi
spherical angle for pitch direction in radians
Definition: Camera.hpp:215
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:230
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
Camera(Camera &&)=default
construct a camera by moving ane existing camera object
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:211
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:184
glm::vec3 mCameraPosition
the cartesian position in world space of the camera
Definition: Camera.hpp:194
Camera & operator=(Camera &&)=default
reassign an existing camera to ourselves
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:198
glm::mat4 mViewMatrix
stores the View Matrix corresponding to the inverse of the Camera's Matrix
Definition: Camera.hpp:189
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:202
Camera & operator=(const Camera &)=default
assign a copy of an existing camera
Camera(const Camera &)=default
construct a copy an existing camera
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:206
GLfloat mCameraRadius
spherical magnitude for direction in world space
Definition: Camera.hpp:219
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:243
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17