Answered step by step
Verified Expert Solution
Link Copied!

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 3D 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 3D scene. Explain how you set up to control the virtual camera for your 3D 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?
* Mouse_Position_Callback()
void ViewManager::Process_Input(GLFWwindow* window){
if (glfwGetKey(window, GLFW_KEY_ESCAPE)== GLFW_PRESS){
glfwSetWindowShouldClose(window, true);}
if (glfwGetKey(window, GLFW_KEY_P)== GLFW_PRESS){
bOrthographicProjection = false;}
else if (glfwGetKey(window, GLFW_KEY_O)== GLFW_PRESS){
bOrthographicProjection = true;}}
glm::mat4 ViewManager::GetProjectionMatrix(){
if (bOrthographicProjection){
// Define orthographic projection parameters (left, right, bottom, top, near, far)
return glm::ortho(-2.0f,2.0f,-1.0f,1.0f,0.1f,100.0f);}
else {
// Use perspective projection with default camera settings
return glm::perspective(glm::radians(g_pCamera->Zoom),(GLfloat)WINDOW_WIDTH /(GLfloat)WINDOW_HEIGHT, 0.1f,100.0f);}}
void ViewManager::Mouse_Scroll_Callback(GLFWwindow* window, double xOffset, double yOffset){
// Update the camera's zoom level based on the mouse scroll offset
g_pCamera->ProcessMouseScroll(yOffset);}
void ViewManager::Mouse_Position_Callback(GLFWwindow* window, double xMousePos, double yMousePos){
if (gFirstMouse){
gLastX = xMousePos;
gLastY = yMousePos;
gFirstMouse = false;}
// calculate the X offset and Y offset values for moving the 3D camera accordingly
float xOffset = xMousePos - gLastX;
float yOffset = gLastY - yMousePos; // reversed since y-coordinates go from bottom to top
// set the current positions into the last position variables
gLastX = xMousePos;
gLastY = yMousePos;
// move the 3D camera according to the calculated offsets
g_pCamera->ProcessMouseMovement(xOffset, yOffset);}
* ProcessKeyboardEvents()
void ViewManager::ProcessKeyboardEvents(){
// close the window if the escape key has been pressed
if (glfwGetKey(m_pWindow, GLFW_KEY_ESCAPE)== GLFW_PRESS){
glfwSetWindowShouldClose(m_pWindow, true);}
// process camera zooming in and out
if (glfwGetKey(m_pWindow, GLFW_KEY_W)== GLFW_PRESS){
g_pCamera->ProcessKeyboard(FORWARD, gDeltaTime);}
if (glfwGetKey(m_pWindow, GLFW_KEY_S)== GLFW_PRESS){
g_pCamera->ProcessKeyboard(BACKWARD, gDeltaTime);}
// process camera panning left and right
if (glfwGetKey(m_pWindow, GLFW_KEY_A)== GLFW_PRESS){
g_pCamera->ProcessKeyboard(LEFT, gDeltaTime);}
if (glfwGetKey(m_pWindow, GLFW_KEY_D)== GLFW_PRESS){
g_pCamera->ProcessKeyboard(RIGHT, gDeltaTime);}
// Process camera upward and downward movement
if (glfwGetKey(m_pWindow, GLFW_KEY_Q)== GLFW_PRESS){
g_pCamera->ProcessKeyboard(UP, gDeltaTime);}
if (glfwGetKey(m_pWindow, GLFW_KEY_E)== GLFW_PRESS){
g_pCamera->ProcessKeyboard(DOWN, gDeltaTime);}}
* PrepareSceneView()
void ViewManager::PrepareSceneView(){
glm::mat4 view;
glm::mat4 projection;
// per-frame 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 = g_pCamera->GetViewMatrix();
// define the current projection matrix
projection = glm::perspective(glm::radians(g_pCamera->Zoom),(GLfloat)WINDOW_WIDTH /(GLfloat)WINDOW_HEIGHT, 0.1f,100.0f);
// if the shader manager object is valid
if (NULL != m_pShaderManager){
// set the view matrix into the shader for proper rendering
m_pShaderManager->setMat4Value(g_ViewName, view);
// set the view matrix into the shader for proper rendering
m_pShaderManager->setMat4Value(g_ProjectionName, projection);
// set the view position of the camera into the shader for proper rendering
m_pShaderManager->setVec3Value("viewPosition", g_pCamera->Position);}}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Aware of the role of HRM in multinational corporations.

Answered: 1 week ago