CSCI441 OpenGL Library 5.9.0
CS@Mines CSCI441 Computer Graphics Course Library
Loading...
Searching...
No Matches
PerspectiveCamera.hpp
1#ifndef CSCI441_PERSPECTIVE_CAMERA_HPP
2#define CSCI441_PERSPECTIVE_CAMERA_HPP
3
4#include "Camera.hpp"
5
6namespace CSCI441 {
7
12 public:
21 explicit PerspectiveCamera(GLfloat aspectRatio = 1.0f, GLfloat fovy = 45.0f, GLfloat nearClipPlane = 0.001f, GLfloat farClipPlane = 1000.0f);
22
28 [[maybe_unused]] virtual void setAspectRatio(GLfloat aspectRatio) final;
29
35 [[maybe_unused]] virtual void setVerticalFOV(GLfloat fovy) final;
36
42 [[maybe_unused]] virtual void setNearClipPlane(GLfloat near) final;
43
49 [[maybe_unused]] virtual void setFarClipPlane(GLfloat far) final;
50
51 protected:
56
57 private:
62 GLfloat _fovy;
66 GLfloat _aspectRatio;
70 GLfloat _nearClipPlane;
74 GLfloat _farClipPlane;
75 };
76
77}
78
80 const GLfloat aspectRatio,
81 const GLfloat fovy,
82 const GLfloat nearClipPlane,
83 const GLfloat farClipPlane
84) : _fovy(fovy),
85 _aspectRatio(aspectRatio),
86 _nearClipPlane(nearClipPlane),
87 _farClipPlane(farClipPlane)
88{
90}
91
92[[maybe_unused]]
93inline void CSCI441::PerspectiveCamera::setAspectRatio(GLfloat aspectRatio) {
94 _aspectRatio = aspectRatio;
95 mUpdateProjectionMatrix();
96}
97
98[[maybe_unused]]
100 _fovy = fovy;
101 mUpdateProjectionMatrix();
102}
103
104[[maybe_unused]]
106 _nearClipPlane = near;
107 mUpdateProjectionMatrix();
108}
109
110[[maybe_unused]]
112 _farClipPlane = far;
113 mUpdateProjectionMatrix();
114}
115
117 mProjectionMatrix = glm::perspective(_fovy, _aspectRatio, _nearClipPlane, _farClipPlane);
118}
119
120#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:37
Abstract Class to represent a perspective camera. Stores aspect ratio and field of view.
Definition: PerspectiveCamera.hpp:11
void mUpdateProjectionMatrix()
computes the perspective projection matrix for the camera
Definition: PerspectiveCamera.hpp:116
virtual void setNearClipPlane(GLfloat near) final
updates the camera's near clip plane
Definition: PerspectiveCamera.hpp:105
virtual void setFarClipPlane(GLfloat far) final
updates the camera's far clip plane
Definition: PerspectiveCamera.hpp:111
virtual void setAspectRatio(GLfloat aspectRatio) final
updates the camera's aspect ratio
Definition: PerspectiveCamera.hpp:93
PerspectiveCamera(GLfloat aspectRatio=1.0f, GLfloat fovy=45.0f, GLfloat nearClipPlane=0.001f, GLfloat farClipPlane=1000.0f)
initializes the Perspective Camera
Definition: PerspectiveCamera.hpp:79
virtual void setVerticalFOV(GLfloat fovy) final
updates the camera's vertical field of view
Definition: PerspectiveCamera.hpp:99
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17