12#ifndef CSCI441_OPENGL3D_ENGINE_HPP
13#define CSCI441_OPENGL3D_ENGINE_HPP
181 [[maybe_unused]]
virtual void handleCameraKeyEvent(
const int key,
const int scancode,
const int action,
const int mods)
final {
182 if( key == GLFW_KEY_LEFT_SHIFT ) {
183 _isLeftShiftDown = (action == GLFW_PRESS || action == GLFW_REPEAT);
184 }
else if( key == GLFW_KEY_RIGHT_SHIFT ) {
185 _isRightShiftDown = (action == GLFW_PRESS || action == GLFW_REPEAT);
197 if( button == GLFW_MOUSE_BUTTON_LEFT ) {
234 OpenGL3DEngine(
int OPENGL_MAJOR_VERSION,
int OPENGL_MINOR_VERSION,
int WINDOW_WIDTH,
int WINDOW_HEIGHT,
const char* WINDOW_TITLE,
bool WINDOW_RESIZABLE = GLFW_FALSE, GLushort NUM_SAMPLES = 0);
262 GLboolean _isLeftShiftDown;
266 GLboolean _isRightShiftDown;
268 void _cleanupChildSelf();
275inline CSCI441::OpenGL3DEngine::OpenGL3DEngine(
const int OPENGL_MAJOR_VERSION,
const int OPENGL_MINOR_VERSION,
const int WINDOW_WIDTH,
const int WINDOW_HEIGHT,
const char* WINDOW_TITLE,
const bool WINDOW_RESIZABLE,
const GLushort NUM_SAMPLES)
276 :
OpenGLEngine(OPENGL_MAJOR_VERSION, OPENGL_MINOR_VERSION, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE, WINDOW_RESIZABLE, NUM_SAMPLES),
277 mpArcballCamera( new
CSCI441::
ArcballCam(2.0f, 30.0f, static_cast<GLfloat>(WINDOW_WIDTH) / static_cast<GLfloat>(WINDOW_HEIGHT)) ),
278 mIsShiftDown( GL_FALSE ),
279 mIsLeftMouseDown( GL_FALSE ),
280 mMousePosition( glm::vec2(0.0f, 0.0f) ),
281 _isLeftShiftDown(GL_FALSE),
282 _isRightShiftDown(GL_FALSE)
294 mpArcballCamera(
nullptr),
295 mIsShiftDown(GL_FALSE),
296 mIsLeftMouseDown(GL_FALSE),
297 mMousePosition( glm::vec2(0.0f, 0.0f) ),
298 _isLeftShiftDown(GL_FALSE),
299 _isRightShiftDown(GL_FALSE)
301 _moveFromSource( src );
307 _moveFromSource(src);
315inline void CSCI441::OpenGL3DEngine::_cleanupChildSelf() {
316 delete mpArcballCamera;
317 mpArcballCamera =
nullptr;
320inline void CSCI441::OpenGL3DEngine::_moveFromSource(OpenGL3DEngine& src) {
321 mpArcballCamera = src.mpArcballCamera;
322 src.mpArcballCamera =
nullptr;
324 mIsShiftDown = src.mIsShiftDown;
325 src.mIsShiftDown = GL_FALSE;
327 mIsLeftMouseDown = src.mIsLeftMouseDown;
328 src.mIsLeftMouseDown = GL_FALSE;
330 mMousePosition = src.mMousePosition;
331 src.mMousePosition = glm::vec2(0.0f, 0.0f);
333 _isLeftShiftDown = src._isLeftShiftDown;
334 src._isLeftShiftDown = GL_FALSE;
336 _isRightShiftDown = src._isRightShiftDown;
337 src._isRightShiftDown = GL_FALSE;
Concrete Arcball Camera implementation with Perspective Projection.
Abstract class engine class to set up window, register callbacks, vaos, textures, and shaders,...
A camera that implements an ArcBall camera model.
Definition: ArcballCam.hpp:23
virtual void setRadius(const GLfloat r) final
sets the camera's radius in world space
Definition: Camera.hpp:159
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:149
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
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 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
virtual glm::vec3 getUpVector() const final
returns the current up vector in world space
Definition: Camera.hpp:108
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:139
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:154
virtual void setUpVector(const glm::vec3 up) final
sets the camera's up vector in world space
Definition: Camera.hpp:144
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:250
Abstract Class to run an OpenGL application with a 3D environment. Creates and contains a default ...
Definition: OpenGL3DEngine.hpp:30
CSCI441::PerspectiveCamera * mpArcballCamera
pointer to the ArcballCam object
Definition: OpenGL3DEngine.hpp:243
void handleCameraAspectRatioEvent(const int width, const int height)
resizes camera aspect ratio
Definition: OpenGL3DEngine.hpp:216
glm::vec2 mMousePosition
current mouse position in screen space
Definition: OpenGL3DEngine.hpp:256
GLboolean mIsShiftDown
if either shift key (left or right) is currently pressed
Definition: OpenGL3DEngine.hpp:248
virtual void setArcballCameraLookAtPoint(const glm::vec3 lookAtPoint) final
set the world space position the arcball camera is looking at and thus centered around
Definition: OpenGL3DEngine.hpp:109
virtual void setMousePosition(const glm::vec2 mousePos) final
set the location of the mouse within the window
Definition: OpenGL3DEngine.hpp:82
virtual void addToArcballCameraAngles(const glm::vec3 angleAdditions) final
moves the arcball spherical object space coordinate by the associated amounts
Definition: OpenGL3DEngine.hpp:138
virtual void setArcballCameraAngles(const glm::vec3 angles) final
sets the object space position of the arcball camera in spherical world coordinates
Definition: OpenGL3DEngine.hpp:88
virtual glm::mat4 getArcballProjectionMatrix() const final
returns the current projection matrix for the arcball camera
Definition: OpenGL3DEngine.hpp:126
virtual glm::vec3 getArcballCameraEyePoint() const noexcept final
the world space position the arcball camera is located at
Definition: OpenGL3DEngine.hpp:98
GLboolean mIsLeftMouseDown
if the mouse left button is currently pressed
Definition: OpenGL3DEngine.hpp:252
virtual GLboolean isShiftDown() const noexcept final
the status of either shift key being down
Definition: OpenGL3DEngine.hpp:66
virtual void handleCameraCursorPosEvent(const double x, const double y) final
moves camera for active cursor movement
Definition: OpenGL3DEngine.hpp:156
OpenGL3DEngine & operator=(const OpenGL3DEngine &)=delete
do not allow engines to be copied
virtual void setArcballCameraUpVector(const glm::vec3 upVector) final
sets the world space vector the arcball camera is oriented upwards along
Definition: OpenGL3DEngine.hpp:120
virtual GLboolean isLeftMouseDown() const noexcept final
the status of the left mouse button being down
Definition: OpenGL3DEngine.hpp:55
virtual void handleCameraMouseButtonEvent(const int button, const int action, const int mods) final
tracks left mouse button state
Definition: OpenGL3DEngine.hpp:196
virtual void setLeftMouseDown(const GLboolean isDown) final
set the status of the left mouse button being down
Definition: OpenGL3DEngine.hpp:60
~OpenGL3DEngine() override
cleans up OpenGL 3D Engine by deleting arcball camera object
Definition: OpenGL3DEngine.hpp:287
OpenGL3DEngine(const OpenGL3DEngine &)=delete
do not allow engines to be copied
virtual glm::vec2 getMousePosition() const noexcept final
the location of the mouse within the window
Definition: OpenGL3DEngine.hpp:77
virtual void handleCameraScrollEvent(const double xOffset, const double yOffset)
zooms camera inward/outward based on scroll direction
Definition: OpenGL3DEngine.hpp:207
virtual void setShiftDown(const GLboolean isDown) final
set the status of the shift keys being down
Definition: OpenGL3DEngine.hpp:71
virtual void updateArcballCameraDirection() final
recomputes the arcball camera's world space position
Definition: OpenGL3DEngine.hpp:147
virtual glm::mat4 getArcballViewMatrix() const final
returns the current view matrix for the arcball camera
Definition: OpenGL3DEngine.hpp:132
virtual glm::vec3 getArcballCameraLookAtPoint() const noexcept final
the world space position the arcball camera is looking at and thus centered around
Definition: OpenGL3DEngine.hpp:104
virtual void handleCameraKeyEvent(const int key, const int scancode, const int action, const int mods) final
tracks if either shift key is currently being pressed
Definition: OpenGL3DEngine.hpp:181
virtual glm::vec3 getArcballCameraUpVector() const noexcept final
the world space vector the arcball camera is oriented upwards along
Definition: OpenGL3DEngine.hpp:115
Abstract Class to run an OpenGL application. The following methods must be overridden:
Definition: OpenGLEngine.hpp:52
OpenGLEngine & operator=(const OpenGLEngine &)=delete
do not allow engines to be copied
virtual int getWindowHeight() const noexcept final
Return the height of the window.
Definition: OpenGLEngine.hpp:148
Abstract Class to represent a perspective camera. Stores aspect ratio and field of view.
Definition: PerspectiveCamera.hpp:22
virtual void setAspectRatio(GLfloat aspectRatio) final
updates the camera's aspect ratio
Definition: PerspectiveCamera.hpp:129
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17