Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i only see a black screen The shapes in the 3 D scene are all white and look flat. The goal is to add two

i only see a black screen The shapes in the 3D scene are all white and look flat. The goal is to add two different light sources at different positions to improve the look of the scene and define the 3D shapes better. Also, add some color to one of the lights to bring more color into the scene. The following picture shows an example 3D scene after the two lighting sources have been added.Create code to address the required functionality. Apply logic and proper syntax to code. All code should be well commented.
DefineObjectMaterials()
void SceneManager::DefineObjectMaterials()
{* SetupSceneLights()
void SceneManager::SetupSceneLights(){
// Define light properties
glm::vec3 light1Position = glm::vec3(5.0f,5.0f,5.0f);
glm::vec3 light1Color = glm::vec3(1.0f,1.0f,1.0f); // White light
glm::vec3 light2Position = glm::vec3(-3.0f,0.0f,5.0f);
glm::vec3 light2Color = glm::vec3(1.0f,0.0f,0.0f); // Red light
// Set the light positions and colors in the shader
m_pShaderManager->setVec3Value("light1.position", light1Position);
m_pShaderManager->setVec3Value("light1.color", light1Color);
m_pShaderManager->setVec3Value("light2.position", light2Position);
m_pShaderManager->setVec3Value("light2.color", light2Color);
// Enable lighting in the shader
m_pShaderManager->setBoolValue(g_UseLightingName, true);}
* PrepareScene()
void SceneManager::PrepareScene(){
// define the materials for objects in the scene
DefineObjectMaterials();
// add and define the light sources for the scene
SetupSceneLights();
m_basicMeshes->LoadBoxMesh();
m_basicMeshes->LoadPlaneMesh();
m_basicMeshes->LoadCylinderMesh();
m_basicMeshes->LoadConeMesh();
m_basicMeshes->LoadSphereMesh();}
* RenderScene()
void SceneManager::RenderScene(){
// declare the variables for the transformations
glm::vec3 scaleXYZ;
float XrotationDegrees =0.0f;
float YrotationDegrees =0.0f;
float ZrotationDegrees =0.0f;
glm::vec3 positionXYZ;
/*** Set needed transformations
// set the XYZ scale for the mesh
scaleXYZ = glm::vec3(20.0f,1.0f,10.0f);
// set the XYZ rotation for the mesh
XrotationDegrees =0.0f;
YrotationDegrees =0.0f;
ZrotationDegrees =0.0f;
// set the XYZ position for the mesh
positionXYZ = glm::vec3(0.0f,0.0f,0.0f);
// set the transformations into memory to be used on the drawn meshes
SetTransformations(
scaleXYZ,
XrotationDegrees,
YrotationDegrees,
ZrotationDegrees,
positionXYZ);
// set the active color values in the shader (RGBA)
SetShaderColor(1,1,1,1);
// draw the mesh with transformation values - this plane is used for the base
m_basicMeshes->DrawPlaneMesh();
/*** Set needed transformations
// set the XYZ scale for the mesh
scaleXYZ = glm::vec3(0.9f,2.8f,0.9f);
// set the XYZ rotation for the mesh
XrotationDegrees =90.0f;
YrotationDegrees =0.0f;
ZrotationDegrees =-15.0f;
// set the XYZ position for the mesh
positionXYZ = glm::vec3(0.0f,0.9f,0.4f);
// set the transformations into memory to be used on the drawn meshes
SetTransformations(
scaleXYZ,
XrotationDegrees,
YrotationDegrees,
ZrotationDegrees,
positionXYZ);
// set the active color values in the shader (RGBA)
SetShaderColor(1,1,1,1);
// draw a filled cylinder shape
m_basicMeshes->DrawCylinderMesh();
/*** Set needed transformations
// set the XYZ scale for the mesh
scaleXYZ = glm::vec3(1.0f,9.0f,1.3f);
// set the XYZ rotation for the mesh
XrotationDegrees =0.0f;
YrotationDegrees =0.0f;
ZrotationDegrees =95.0f;
// set the XYZ position for the mesh
positionXYZ = glm::vec3(0.2f,2.27f,2.0f);
// set the transformations into memory to be used on the drawn meshes
SetTransformations(
scaleXYZ,
XrotationDegrees,
YrotationDegrees,
ZrotationDegrees,
positionXYZ);
// set the active color values in the shader (RGBA)
SetShaderColor(1,1,1,1);
// draw a filled box shape
m_basicMeshes->DrawBoxMesh();
/*** Set needed transformations
// set the XYZ scale for the mesh
scaleXYZ = glm::vec3(1.7f,1.5f,1.5f);
// set the XYZ rotation for the mesh
XrotationDegrees =0.0f;
YrotationDegrees =40.0f;
ZrotationDegrees =8.0f;
// set the XYZ position for the mesh
positionXYZ = glm::vec3(3.3f,3.83f,2.19f);
// set the transformations into memory to be used on the drawn meshes
SetTransformations(
scaleXYZ,
XrotationDegrees,
YrotationDegrees,
ZrotationDegrees,
positionXYZ);
// set the active color values in the shader (RGBA)
SetShaderColor(1,1,1,1);
// draw a filled box shape
m_basicMeshes->DrawBoxMesh();
/*** Set needed transformations
// set the XYZ scale for the mesh
scaleXYZ = glm::vec3(1.0f,1.0f,1.0f);
// set the XYZ rotation for the mesh
XrotationDegrees =0.0f;
YrotationDegrees =0.0f;
ZrotationDegrees =0.0f;
// set the XYZ position for the mesh
positionXYZ = glm::vec3(3.1f,5.6f,2.5f);
// set the transformations into memo

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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

2. What abilities are possible because humans use symbols?

Answered: 1 week ago

Question

1. How are language and thought related?

Answered: 1 week ago

Question

4. How do rules guide verbal communication?

Answered: 1 week ago