15#ifndef CSCI441_CAMERA_HPP
16#define CSCI441_CAMERA_HPP
20#ifdef CSCI441_USE_GLEW
26#include <glm/mat4x4.hpp>
27#include <glm/vec3.hpp>
28#include <glm/gtc/constants.hpp>
29#include <glm/gtc/matrix_transform.hpp>
59 [[maybe_unused]]
virtual void moveForward(GLfloat movementFactor) = 0;
65 [[maybe_unused]]
virtual void moveBackward(GLfloat movementFactor) = 0;
77 [[maybe_unused]] [[maybe_unused]]
virtual void rotate(GLfloat dTheta, GLfloat dPhi);
228 void _clampCameraPhi();
233 mProjectionMatrix( glm::mat4(1.0f) ),
234 mViewMatrix( glm::mat4(1.0f) ),
235 mCameraPosition( glm::vec3(0.0f, 0.0f, 0.0f ) ),
236 mCameraDirection( glm::vec3(0.0f, 0.0f, -1.0f ) ),
237 mCameraLookAtPoint( glm::vec3(0.0f, 0.0f, -1.0f ) ),
238 mCameraUpVector( glm::vec3(0.0f, 1.0f, 0.0f ) ),
239 mCameraTheta( 0.0f ),
240 mCameraPhi( glm::pi<float>() / 2.0f ),
241 mCameraRadius( 1.0f ) {
246 mCameraTheta += dTheta;
249 recomputeOrientation();
252inline void CSCI441::Camera::_clampCameraPhi() {
253 if(mCameraPhi <= 0.0f) mCameraPhi = 0.0f + 0.001f;
254 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:39
virtual GLfloat getRadius() const final
returns the current radius in world space
Definition: Camera.hpp:123
GLfloat mCameraPhi
spherical angle for pitch direction in radians
Definition: Camera.hpp:217
virtual void setRadius(const GLfloat r) final
sets the camera's radius in world space
Definition: Camera.hpp:154
virtual GLfloat getPhi() const final
returns the current phi value in radians
Definition: Camera.hpp:118
virtual void setTheta(const GLfloat t) final
sets the camera's theta angle in radians
Definition: Camera.hpp:144
Camera()
create a default camera at the origin, looking down the negative Z axis oriented with the world coord...
Definition: Camera.hpp:232
virtual glm::vec3 getLookAtPoint() const final
returns the current lookAt point in world space
Definition: Camera.hpp:103
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:82
virtual glm::mat4 getViewMatrix() const final
returns the current view matrix for the associated camera
Definition: Camera.hpp:93
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:129
GLfloat mCameraTheta
spherical angle for yaw direction in radians
Definition: Camera.hpp:213
virtual GLfloat getTheta() const final
returns the current theta value in radians
Definition: Camera.hpp:113
virtual glm::vec3 getPosition() const final
returns the current camera position in world space
Definition: Camera.hpp:98
glm::mat4 mProjectionMatrix
stores the Projection Matrix
Definition: Camera.hpp:186
glm::vec3 mCameraPosition
the cartesian position in world space of the camera
Definition: Camera.hpp:196
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:108
virtual ~Camera()=default
properly destroy concrete children
glm::vec3 mCameraDirection
the cartesian direction the camera is facing in world space
Definition: Camera.hpp:200
glm::mat4 mViewMatrix
stores the View Matrix corresponding to the inverse of the Camera's Matrix
Definition: Camera.hpp:191
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:134
glm::vec3 mCameraLookAtPoint
the world space point in front of the camera
Definition: Camera.hpp:204
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:88
virtual void setPhi(const GLfloat p) final
sets the camera's phi angle in radians
Definition: Camera.hpp:149
virtual void setUpVector(const glm::vec3 up) final
sets the camera's up vector in world space
Definition: Camera.hpp:139
glm::vec3 mCameraUpVector
the up vector of the camera specified in world space
Definition: Camera.hpp:208
GLfloat mCameraRadius
spherical magnitude for direction in world space
Definition: Camera.hpp:221
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:245
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17