Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Z I need help adjusting my code, the shape i need to create is an hourglass out of two pyramids, but as you can see

Z I need help adjusting my code, the shape i need to create is an hourglass out of two pyramids, but as you can see they arent pyramids
#include "SceneManager.h"
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#endif
#include
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)
{
glm::mat4 modelView;
glm::mat4 scale;
glm::mat4 rotationX;
glm::mat4 rotationY;
glm::mat4 rotationZ;
glm::mat4 translation;
scale = glm::scale(scaleXYZ);
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));
translation = glm::translate(positionXYZ);
modelView = translation * rotationX * rotationY * rotationZ * scale;
if (NULL != m_pShaderManager)
{
m_pShaderManager->setMat4Value(g_ModelName, modelView);
}
}
void SceneManager::SetShaderColor(
float redColorValue,
float greenColorValue,
float blueColorValue,
float alphaValue)
{
glm::vec4 currentColor;
currentColor.r = redColorValue;
currentColor.g = greenColorValue;
currentColor.b = blueColorValue;
currentColor.a = alphaValue;
if (NULL != m_pShaderManager)
{
m_pShaderManager->setIntValue(g_UseTextureName, false);
m_pShaderManager->setVec4Value(g_ColorValueName, currentColor);
}
}
void SceneManager::PrepareScene()
{
m_basicMeshes->LoadPyramid4Mesh();
}
void SceneManager::RenderScene()
{
// Transformation for the top pyramid (top of the hourglass)
glm::vec3 scaleXYZ_top = glm::vec3(1.0f,1.0f,1.0f);
float XrotationDegrees_top =180.0f; // Invert the pyramid
float YrotationDegrees_top =0.0f;
float ZrotationDegrees_top =0.0f;
glm::vec3 positionXYZ_top = glm::vec3(0.0f,0.5f,0.0f); // Move it upwards
SetTransformations(
scaleXYZ_top,
XrotationDegrees_top,
YrotationDegrees_top,
ZrotationDegrees_top,
positionXYZ_top);
SetShaderColor(1,1,1,1);
m_basicMeshes->DrawPyramid4Mesh(); // Draw the top pyramid
// Transformation for the bottom pyramid (bottom of the hourglass)
glm::vec3 scaleXYZ_bottom = glm::vec3(1.0f,1.0f,1.0f);
float XrotationDegrees_bottom =0.0f; // No rotation needed
float YrotationDegrees_bottom =0.0f;
float ZrotationDegrees_bottom =0.0f;
glm::vec3 positionXYZ_bottom = glm::vec3(0.0f,-0.5f,0.0f); // Move it downwards
SetTransformations(
scaleXYZ_bottom,
XrotationDegrees_bottom,
YrotationDegrees_bottom,
ZrotationDegrees_bottom,
positionXYZ_bottom);
SetShaderColor(1,1,1,1);
m_basicMeshes->DrawPyramid4Mesh(); // Draw the bottom pyramid
}
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 Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions