Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Reflection Justify development choices for your 3 D scene. Think about why you chose your selected objects. The selected objects are the desk top monitor
Reflection Justify development choices for your D scene. Think about why you chose your selected objects. The selected objects are the desk top monitor and keyboard, cell phone, sticky notes, pen, and the jar. Also consider how you were able to program for the required functionality. Explain how a user can navigate your D scene. Explain how you set up to control the virtual camera for your D scene using different input devices. Explain the custom functions in your program that you are using to make your code more modular and organized. Ask yourself, what does the function you developed do and how is it reusable?
MousePositionCallback
void ViewManager::ProcessInputGLFWwindow window
if glfwGetKeywindow GLFWKEYESCAPE GLFWPRESS
glfwSetWindowShouldClosewindow true;
if glfwGetKeywindow GLFWKEYP GLFWPRESS
bOrthographicProjection false;
else if glfwGetKeywindow GLFWKEYO GLFWPRESS
bOrthographicProjection true;
glm::mat ViewManager::GetProjectionMatrix
if bOrthographicProjection
Define orthographic projection parameters left right, bottom, top, near, far
return glm::orthoffffff;
else
Use perspective projection with default camera settings
return glm::perspectiveglm::radiansgpCameraZoomGLfloatWINDOWWIDTH GLfloatWINDOWHEIGHT, ff;
void ViewManager::MouseScrollCallbackGLFWwindow window, double xOffset, double yOffset
Update the camera's zoom level based on the mouse scroll offset
gpCameraProcessMouseScrollyOffset;
void ViewManager::MousePositionCallbackGLFWwindow window, double xMousePos, double yMousePos
if gFirstMouse
gLastX xMousePos;
gLastY yMousePos;
gFirstMouse false;
calculate the X offset and Y offset values for moving the D camera accordingly
float xOffset xMousePos gLastX;
float yOffset gLastY yMousePos; reversed since ycoordinates go from bottom to top
set the current positions into the last position variables
gLastX xMousePos;
gLastY yMousePos;
move the D camera according to the calculated offsets
gpCameraProcessMouseMovementxOffset yOffset;
ProcessKeyboardEvents
void ViewManager::ProcessKeyboardEvents
close the window if the escape key has been pressed
if glfwGetKeympWindow, GLFWKEYESCAPE GLFWPRESS
glfwSetWindowShouldClosempWindow, true;
process camera zooming in and out
if glfwGetKeympWindow, GLFWKEYW GLFWPRESS
gpCameraProcessKeyboardFORWARD gDeltaTime;
if glfwGetKeympWindow, GLFWKEYS GLFWPRESS
gpCameraProcessKeyboardBACKWARD gDeltaTime;
process camera panning left and right
if glfwGetKeympWindow, GLFWKEYA GLFWPRESS
gpCameraProcessKeyboardLEFT gDeltaTime;
if glfwGetKeympWindow, GLFWKEYD GLFWPRESS
gpCameraProcessKeyboardRIGHT gDeltaTime;
Process camera upward and downward movement
if glfwGetKeympWindow, GLFWKEYQ GLFWPRESS
gpCameraProcessKeyboardUP gDeltaTime;
if glfwGetKeympWindow, GLFWKEYE GLFWPRESS
gpCameraProcessKeyboardDOWN gDeltaTime;
PrepareSceneView
void ViewManager::PrepareSceneView
glm::mat view;
glm::mat projection;
perframe timing
float currentFrame glfwGetTime;
gDeltaTime currentFrame gLastFrame;
gLastFrame currentFrame;
process any keyboard events that may be waiting in the
event queue
ProcessKeyboardEvents;
get the current view matrix from the camera
view gpCameraGetViewMatrix;
define the current projection matrix
projection glm::perspectiveglm::radiansgpCameraZoomGLfloatWINDOWWIDTH GLfloatWINDOWHEIGHT, ff;
if the shader manager object is valid
if NULL mpShaderManager
set the view matrix into the shader for proper rendering
mpShaderManagersetMatValuegViewName, view;
set the view matrix into the shader for proper rendering
mpShaderManagersetMatValuegProjectionName, projection;
set the view position of the camera into the shader for proper rendering
mpShaderManagersetVecValueviewPosition gpCameraPosition;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started