CSCI441 OpenGL Library 6.1.2.0
CS@Mines CSCI441 Computer Graphics Course Library
Loading...
Searching...
No Matches
PerspectiveCamera.hpp
Go to the documentation of this file.
1
12#ifndef CSCI441_PERSPECTIVE_CAMERA_HPP
13#define CSCI441_PERSPECTIVE_CAMERA_HPP
14
15#include "Camera.hpp"
16
17namespace CSCI441 {
18
23 public:
32 explicit PerspectiveCamera(GLfloat aspectRatio = 1.0f, GLfloat fovy = glm::quarter_pi<GLfloat>(), GLfloat nearClipPlane = 0.001f, GLfloat farClipPlane = 1000.0f);
33
37 ~PerspectiveCamera() override = default;
38
44 [[maybe_unused]] virtual void setAspectRatio(GLfloat aspectRatio) final;
45
52 [[maybe_unused]] virtual void setVerticalFOV(GLfloat fovy) final;
53
59 [[maybe_unused]] virtual void setNearClipPlane(GLfloat near) final;
60
66 [[maybe_unused]] virtual void setFarClipPlane(GLfloat far) final;
67
68 protected:
73
83
93
94 private:
99 GLfloat _fovy;
103 GLfloat _aspectRatio;
107 GLfloat _nearClipPlane;
111 GLfloat _farClipPlane;
112 };
113
114}
115
117 const GLfloat aspectRatio,
118 const GLfloat fovy,
119 const GLfloat nearClipPlane,
120 const GLfloat farClipPlane
121) : _fovy(fovy),
122 _aspectRatio(aspectRatio),
123 _nearClipPlane(nearClipPlane),
124 _farClipPlane(farClipPlane)
125{
127}
128
129[[maybe_unused]]
130inline void CSCI441::PerspectiveCamera::setAspectRatio(const GLfloat aspectRatio) {
131 _aspectRatio = aspectRatio;
132 mUpdateProjectionMatrix();
133}
134
135[[maybe_unused]]
136inline void CSCI441::PerspectiveCamera::setVerticalFOV(const GLfloat fovy) {
137 _fovy = fovy;
138 mUpdateProjectionMatrix();
139}
140
141[[maybe_unused]]
142inline void CSCI441::PerspectiveCamera::setNearClipPlane(const GLfloat near) {
143 _nearClipPlane = near;
144 mUpdateProjectionMatrix();
145}
146
147[[maybe_unused]]
148inline void CSCI441::PerspectiveCamera::setFarClipPlane(const GLfloat far) {
149 _farClipPlane = far;
150 mUpdateProjectionMatrix();
151}
152
154 mProjectionMatrix = glm::perspective(_fovy, _aspectRatio, _nearClipPlane, _farClipPlane);
155}
156
157#endif//CSCI441_PERSPECTIVE_CAMERA_HPP
Abstract Camera class to be placed (position and orientation) within our scene.
Abstract Class to represent a synthetic camera. The following methods must be overridden:
Definition: Camera.hpp:39
Abstract Class to represent a perspective camera. Stores aspect ratio and field of view.
Definition: PerspectiveCamera.hpp:22
PerspectiveCamera(const PerspectiveCamera &)=default
construct a copy an existing camera
void mUpdateProjectionMatrix()
computes the perspective projection matrix for the camera
Definition: PerspectiveCamera.hpp:153
PerspectiveCamera & operator=(const PerspectiveCamera &)=default
assign a copy of an existing camera
PerspectiveCamera(GLfloat aspectRatio=1.0f, GLfloat fovy=glm::quarter_pi< GLfloat >(), GLfloat nearClipPlane=0.001f, GLfloat farClipPlane=1000.0f)
initializes the Perspective Camera
Definition: PerspectiveCamera.hpp:116
virtual void setNearClipPlane(GLfloat near) final
updates the camera's near clip plane
Definition: PerspectiveCamera.hpp:142
PerspectiveCamera(PerspectiveCamera &&)=default
construct a camera by moving ane existing camera object
virtual void setFarClipPlane(GLfloat far) final
updates the camera's far clip plane
Definition: PerspectiveCamera.hpp:148
virtual void setAspectRatio(GLfloat aspectRatio) final
updates the camera's aspect ratio
Definition: PerspectiveCamera.hpp:130
~PerspectiveCamera() override=default
properly destroy concrete children
PerspectiveCamera & operator=(PerspectiveCamera &&)=default
reassign an existing camera to ourselves
virtual void setVerticalFOV(GLfloat fovy) final
updates the camera's vertical field of view
Definition: PerspectiveCamera.hpp:136
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17