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 ) {
233 OpenGL3DEngine(
int OPENGL_MAJOR_VERSION,
int OPENGL_MINOR_VERSION,
int WINDOW_WIDTH,
int WINDOW_HEIGHT,
const char* WINDOW_TITLE,
bool WINDOW_RESIZABLE = GLFW_FALSE);
261 GLboolean _isLeftShiftDown;
265 GLboolean _isRightShiftDown;
267 void _cleanupChildSelf();
274inline 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)
275 :
OpenGLEngine(OPENGL_MAJOR_VERSION, OPENGL_MINOR_VERSION, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE, WINDOW_RESIZABLE),
276 mpArcballCamera( new
CSCI441::
ArcballCam(2.0f, 30.0f, static_cast<GLfloat>(WINDOW_WIDTH) / static_cast<GLfloat>(WINDOW_HEIGHT)) ),
277 mIsShiftDown( GL_FALSE ),
278 mIsLeftMouseDown( GL_FALSE ),
279 mMousePosition( glm::vec2(0.0f, 0.0f) ),
280 _isLeftShiftDown(GL_FALSE),
281 _isRightShiftDown(GL_FALSE)
293 mpArcballCamera(
nullptr),
294 mIsShiftDown(GL_FALSE),
295 mIsLeftMouseDown(GL_FALSE),
296 mMousePosition( glm::vec2(0.0f, 0.0f) ),
297 _isLeftShiftDown(GL_FALSE),
298 _isRightShiftDown(GL_FALSE)
300 _moveFromSource( src );
306 _moveFromSource(src);
314inline void CSCI441::OpenGL3DEngine::_cleanupChildSelf() {
315 delete mpArcballCamera;
316 mpArcballCamera =
nullptr;
319inline void CSCI441::OpenGL3DEngine::_moveFromSource(OpenGL3DEngine& src) {
320 mpArcballCamera = src.mpArcballCamera;
321 src.mpArcballCamera =
nullptr;
323 mIsShiftDown = src.mIsShiftDown;
324 src.mIsShiftDown = GL_FALSE;
326 mIsLeftMouseDown = src.mIsLeftMouseDown;
327 src.mIsLeftMouseDown = GL_FALSE;
329 mMousePosition = src.mMousePosition;
330 src.mMousePosition = glm::vec2(0.0f, 0.0f);
332 _isLeftShiftDown = src._isLeftShiftDown;
333 src._isLeftShiftDown = GL_FALSE;
335 _isRightShiftDown = src._isRightShiftDown;
336 src._isRightShiftDown = GL_FALSE;
Concrete Arcball Camera implementation with Perspective Projection.
Abstract class engine class to setup window, register callbacks, vaos, textures, and shaders,...
A camera that implements an ArcBall camera model.
Definition: ArcballCam.hpp:23
void recomputeOrientation() override
converts spherical theta & phi to cartesian x,y,z direction vector
Definition: ArcballCam.hpp:120
void moveForward(GLfloat movementFactor) override
updates the camera's position by decreasing the camera's radius
Definition: ArcballCam.hpp:129
void moveBackward(GLfloat movementFactor) override
updates the camera's position by increasing the camera's radius
Definition: ArcballCam.hpp:135
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
virtual glm::vec3 getLookAtPoint() const final
returns the current lookAt point in world space
Definition: Camera.hpp:101
virtual glm::mat4 getViewMatrix() const final
returns the current view matrix for the associated camera
Definition: Camera.hpp:91
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
virtual glm::vec3 getUpVector() const final
returns the current up vector in world space
Definition: Camera.hpp:106
virtual void setLookAtPoint(const glm::vec3 lookAt) final
sets the camera's lookAt point in world space
Definition: Camera.hpp:132
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
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
Abstract Class to run an OpenGL application with a 3D environment. Creates and contains a default ...
Definition: OpenGL3DEngine.hpp:30
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:255
GLboolean mIsShiftDown
if either shift key (left or right) is currently pressed
Definition: OpenGL3DEngine.hpp:247
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:251
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
CSCI441::ArcballCam * mpArcballCamera
pointer to the ArcballCam object
Definition: OpenGL3DEngine.hpp:242
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:286
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:39
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:121
virtual void setAspectRatio(GLfloat aspectRatio) final
updates the camera's aspect ratio
Definition: PerspectiveCamera.hpp:118
CSCI441 Helper Functions for OpenGL.
Definition: ArcballCam.hpp:17