Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, im just trying to add these shape to this code and cannot do so without getting errors please help c + + #include SceneManager.h

Hello, im just trying to add these shape to this code and cannot do so without getting errors please help c++
#include "SceneManager.h"
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#endif
#include
// declaration of global variables
namespace
{
const char* g_ModelName = "model";
const char* g_ColorValueName = "objectColor";
const char* g_TextureValueName = "objectTexture";
const char* g_UseTextureName = "bUseTexture";
const char* g_UseLightingName = "bUseLighting";
}
SceneManager::SceneManager(ShaderManager *pShaderManager)
{
m_pShaderManager = pShaderManager;
m_basicMeshes = new ShapeMeshes();
}
SceneManager::~SceneManager()
{
m_pShaderManager = NULL;
delete m_basicMeshes;
m_basicMeshes = NULL;
}
void SceneManager::SetTransformations(
glm::vec3 scaleXYZ,
float XrotationDegrees,
float YrotationDegrees,
float ZrotationDegrees,
glm::vec3 positionXYZ)
{
// variables for this method
glm::mat4 modelView;
glm::mat4 scale;
glm::mat4 rotationX;
glm::mat4 rotationY;
glm::mat4 rotationZ;
glm::mat4 translation;
// set the scale value in the transform buffer
scale = glm::scale(scaleXYZ);
// set the rotation values in the transform buffer
rotationX = glm::rotate(glm::radians(XrotationDegrees), glm::vec3(1.0f,0.0f,0.0f));
rotationY = glm::rotate(glm::radians(YrotationDegrees), glm::vec3(0.0f,1.0f,0.0f));
rotationZ = glm::rotate(glm::radians(ZrotationDegrees), glm::vec3(0.0f,0.0f,1.0f));
// set the translation value in the transform buffer
translation = glm::translate(positionXYZ);
// matrix math for calculating the final model matrix
modelView = translation * rotationX * rotationY * rotationZ * scale;
if (NULL != m_pShaderManager)
{
// pass the model matrix into the shader
m_pShaderManager->setMat4Value(g_ModelName, modelView);
}
}
void SceneManager::SetShaderColor(
float redColorValue,
float greenColorValue,
float blueColorValue,
float alphaValue)
{
// variables for this method
glm::vec4 currentColor;
currentColor.r = redColorValue;
currentColor.g = greenColorValue;
currentColor.b = blueColorValue;
currentColor.a = alphaValue;
if (NULL != m_pShaderManager)
{
// pass the color values into the shader
m_pShaderManager->setIntValue(g_UseTextureName, false);
m_pShaderManager->setVec4Value(g_ColorValueName, currentColor);
}
}
void SceneManager::PrepareScene()
{
m_basicMeshes->LoadPlaneMesh();
m_basicMeshes->LoadBoxMesh();
m_basicMeshes->LoadSphereMesh();
m_basicMeshes->LoadCylinderMesh();
}
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 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 color values into the shader
SetShaderColor(1,1,1,1);
// draw the mesh with transformation values
m_basicMeshes->DrawPlaneMesh();
// set the XYZ scale for the mesh
scaleXYZ = glm::vec3(20.0f,1.0f,10.0f);
// set the XYZ rotation for the mesh
XrotationDegrees =90.0f;
YrotationDegrees =0.0f;
ZrotationDegrees =0.0f;
// set the XYZ position for the mesh
positionXYZ = glm::vec3(0.0f,9.0f,-10.0f);
// set the transformations into memory to be used on the drawn meshes
SetTransformations(
scaleXYZ,
XrotationDegrees,
YrotationDegrees,
ZrotationDegrees,
positionXYZ);
// set the color values into the shader
SetShaderColor(1,1,1,1);
// draw the mesh with transformation values
m_basicMeshes->DrawPlaneMesh();
}
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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

How autonomous should the target be left after the merger deal?

Answered: 1 week ago