Я пишу белый треугольник, перевернутый над другим белым треугольником, чтобы их кончики соприкасались, образуя форму песочных часов. Мне нужна помощь в исправлении моего кода.
#include "SceneManager.h"
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#endif
#include
{
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 to calculate 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)
{
// set the color values into the shader
m_pShaderManager->setIntValue(g_UseTextureName, false);
m_pShaderManager->setVec4Value(g_ColorValueName, currentColor);
}
}
void SceneManager::PrepareScene()
{
// only one instance of a particular mesh needs to be
// loaded in memory no matter how many times it is drawn
// in the rendered 3D scene
m_basicMeshes->LoadPyramid4Mesh();
}
void SceneManager::RenderScene() {
// Set up the first pyramid transformations
glPushMatrix(); // Save the current matrix
// Apply transformations to the first pyramid
glTranslatef(0.0f, 1.0f, 0.0f); // Move it up so the tips meet
// Code to render the first pyramid
RenderPyramid();
glPopMatrix(); // Restore the saved matrix
// Set up the second pyramid transformations
glPushMatrix(); // Save the current matrix
// Apply transformations to the second pyramid
glRotatef(180.0f, 1.0f, 0.0f, 0.0f); // Invert the pyramid by rotating 180 degrees on `your text`the X-axis
glTranslatef(0.0f, -1.0f, 0.0f); // Move it down so the tips meet
// Code to render the second pyramid
RenderPyramid();
glPopMatrix(); // Restore the saved matrix
}
Подробнее здесь: https://stackoverflow.com/questions/785 ... -tips-meet
OPENGL Белый треугольник, перевернутый над другим белым треугольником так, что их кончики встречаются, образуя форму пес ⇐ C++
Программы на C++. Форум разработчиков
1716783177
Anonymous
Я пишу белый треугольник, перевернутый над другим белым треугольником, чтобы их кончики соприкасались, образуя форму песочных часов. Мне нужна помощь в исправлении моего кода.
#include "SceneManager.h"
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#endif
#include
{
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 to calculate 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)
{
// set the color values into the shader
m_pShaderManager->setIntValue(g_UseTextureName, false);
m_pShaderManager->setVec4Value(g_ColorValueName, currentColor);
}
}
void SceneManager::PrepareScene()
{
// only one instance of a particular mesh needs to be
// loaded in memory no matter how many times it is drawn
// in the rendered 3D scene
m_basicMeshes->LoadPyramid4Mesh();
}
void SceneManager::RenderScene() {
// Set up the first pyramid transformations
glPushMatrix(); // Save the current matrix
// Apply transformations to the first pyramid
glTranslatef(0.0f, 1.0f, 0.0f); // Move it up so the tips meet
// Code to render the first pyramid
RenderPyramid();
glPopMatrix(); // Restore the saved matrix
// Set up the second pyramid transformations
glPushMatrix(); // Save the current matrix
// Apply transformations to the second pyramid
glRotatef(180.0f, 1.0f, 0.0f, 0.0f); // Invert the pyramid by rotating 180 degrees on `your text`the X-axis
glTranslatef(0.0f, -1.0f, 0.0f); // Move it down so the tips meet
// Code to render the second pyramid
RenderPyramid();
glPopMatrix(); // Restore the saved matrix
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78536616/opengl-a-white-triangle-inverted-above-another-white-triangle-so-their-tips-meet[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия