Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I cant seem to get my texture to go on top of the keyboard box. Please help * LoadSceneTextures ( ) void SceneManager::LoadSceneTextures ( )

I cant seem to get my texture to go on top of the keyboard box. Please help
* LoadSceneTextures()
void SceneManager::LoadSceneTextures(){
bool bReturn = false;
bReturn = CreateGLTexture(
"textures/wood.jpg", "wood");
bReturn = CreateGLTexture(
"textures/glass1.jpg", "glass1");
bReturn = CreateGLTexture(
"textures/glass2.jpg", "glass2");
bReturn = CreateGLTexture(
"textures/glass3.jpg", "glass3");
bReturn = CreateGLTexture(
"textures/gold.jpg", "gold");
bReturn = CreateGLTexture(
"textures/keyboard.jpg", "keyboard");
bReturn = CreateGLTexture(
"textures/stickynote.jpg", "stickynote");
BindGLTextures();}
* DefineObjectMaterials()
void SceneManager::DefineObjectMaterials()// This function will set material properties such as diffuse, specular, ambient, etc.{
OBJECT_MATERIAL goldMaterial;
goldMaterial.ambientColor = glm::vec3(0.2f,0.2f,0.1f);
goldMaterial.ambientStrength =0.4f;
goldMaterial.diffuseColor = glm::vec3(0.3f,0.3f,0.2f);
goldMaterial.specularColor = glm::vec3(0.6f,0.5f,0.4f);
goldMaterial.shininess =44.0;
goldMaterial.tag = "gold";
m_objectMaterials.push_back(goldMaterial);
OBJECT_MATERIAL woodMaterial;
woodMaterial.ambientColor = glm::vec3(0.4f,0.3f,0.1f);
woodMaterial.ambientStrength =0.2f;
woodMaterial.diffuseColor = glm::vec3(0.3f,0.2f,0.1f);
woodMaterial.specularColor = glm::vec3(0.1f,0.1f,0.1f);
woodMaterial.shininess =0.3;
woodMaterial.tag = "wood";
m_objectMaterials.push_back(woodMaterial);
OBJECT_MATERIAL glassMaterial;
glassMaterial.ambientColor = glm::vec3(0.4f,0.4f,0.4f);
glassMaterial.ambientStrength =0.3f;
glassMaterial.diffuseColor = glm::vec3(0.3f,0.3f,0.3f);
glassMaterial.specularColor = glm::vec3(0.6f,0.6f,0.6f);
glassMaterial.shininess =85.0;
glassMaterial.tag = "glass";
m_objectMaterials.push_back(glassMaterial);
OBJECT_MATERIAL keyboardMaterial;
keyboardMaterial.ambientColor = glm::vec3(0.4f,0.3f,0.1f);
keyboardMaterial.ambientStrength =0.2f;
keyboardMaterial.diffuseColor = glm::vec3(0.3f,0.2f,0.1f);
keyboardMaterial.specularColor = glm::vec3(0.1f,0.1f,0.1f);
keyboardMaterial.shininess =0.7;
keyboardMaterial.tag = "keyboard";
m_objectMaterials.push_back(keyboardMaterial);
OBJECT_MATERIAL stickynoteMaterial;
stickynoteMaterial.ambientColor = glm::vec3(0.4f,0.3f,0.1f);
stickynoteMaterial.ambientStrength =0.2f;
stickynoteMaterial.diffuseColor = glm::vec3(0.3f,0.2f,0.1f);
stickynoteMaterial.specularColor = glm::vec3(0.1f,0.1f,0.1f);
stickynoteMaterial.shininess =0.7;
stickynoteMaterial.tag = "stickynote";
m_objectMaterials.push_back(stickynoteMaterial);}
* PrepareScene()
void SceneManager::PrepareScene(){
// load the textures for the 3D scene
LoadSceneTextures();
// define the materials for objects in the scene
DefineObjectMaterials();
// add and define the light sources for the scene
SetupSceneLights();
m_basicMeshes->LoadPlaneMesh();
m_basicMeshes->LoadBoxMesh();
m_basicMeshes->LoadCylinderMesh();
m_basicMeshes->LoadTaperedCylinderMesh();
m_basicMeshes->LoadConeMesh();}
* 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;
glm::mat4 scale;
glm::mat4 rotation;
glm::mat4 rotation2;
glm::mat4 translation;
glm::mat4 model;
/*** 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);
//SetShaderColor(1,1,1,1);
SetShaderTexture("wood");
//SetTextureUVScale(1.0,1.0);
SetShaderMaterial("wood");
// draw the mesh with transformation values
m_basicMeshes->DrawPlaneMesh();
/****************************************************************/
// Draw the keyboard (a box 2)
// set the XYZ scale for the mesh
scaleXYZ = glm::vec3(7.0f,0.5f,2.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.25f,-2.5f);
// set the transformations into memory to be used on the drawn meshes
SetTransformations(
scaleXYZ,
XrotationDegrees,
YrotationDegrees,
ZrotationDegrees,
positionXYZ);
//SetShaderColor(0.3,0.3,0.3,1.0);
//SetShaderTexture("keyboard");
//SetTextureUVScale(1.0,1.0);
SetShaderMaterial("Keyboard");
// draw the mesh with transformation values
m_basicMeshes->DrawBoxMesh();

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

Students also viewed these Databases questions