Colors now working correcly.
This commit is contained in:
@@ -4,16 +4,15 @@
|
||||
#include <string>
|
||||
|
||||
#include "Component.h"
|
||||
#include "Color.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Model : Component
|
||||
{
|
||||
Model() : Visible(true), ShadowCaster(true), Transparent(false) { }
|
||||
Model() : Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)), Visible(true), ShadowCaster(true), Transparent(false) { }
|
||||
std::string ModelFile;
|
||||
Color Color;
|
||||
glm::vec4 Color;
|
||||
bool Visible;
|
||||
bool ShadowCaster;
|
||||
bool Transparent;
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
#include <string>
|
||||
|
||||
#include "Component.h"
|
||||
#include "Color.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Sprite : Component
|
||||
{
|
||||
Sprite() : Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)) { }
|
||||
|
||||
std::string SpriteFile;
|
||||
Color Color;
|
||||
glm::vec4 Color;
|
||||
|
||||
virtual Sprite* Clone() const override { return new Sprite(*this); }
|
||||
};
|
||||
|
||||
+2
-2
@@ -25,13 +25,13 @@ public:
|
||||
vp1->X = 0;
|
||||
vp1->Width = 640;
|
||||
vp1->Height = 720 / 2;
|
||||
new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
//new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
|
||||
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
||||
vp2->X = vp1->Right();
|
||||
vp2->Width = 640;
|
||||
vp2->Height = 720 / 2;
|
||||
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
//new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
|
||||
auto vpc = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
||||
vpc->Y = 720 / 2;
|
||||
|
||||
+14
-7
@@ -44,6 +44,10 @@ public:
|
||||
{
|
||||
EntityID entity = pair.first;
|
||||
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateComponent)
|
||||
continue;
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (!transform)
|
||||
continue;
|
||||
@@ -78,12 +82,11 @@ public:
|
||||
|
||||
float textureRepeat = blendmapComponent->TextureRepeats;
|
||||
|
||||
EnqueueBlendMapModel(modelAsset, RedTexture, GreenTexture, BlueTexture, textureRepeat, modelMatrix);
|
||||
EnqueueBlendMapModel(modelAsset, RedTexture, GreenTexture, BlueTexture, textureRepeat, modelMatrix, modelComponent->Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
float transparent = modelComponent->Transparent;
|
||||
EnqueueModel(modelAsset, modelMatrix, transparent);
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -100,7 +103,7 @@ public:
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::toMat4(orientation2D)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueSprite(textureAsset, modelMatrix);
|
||||
EnqueueSprite(textureAsset, modelMatrix, spriteComponent->Color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +155,7 @@ private:
|
||||
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent)
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
@@ -166,6 +169,8 @@ private:
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Transparent = transparent;
|
||||
job.Color = color;
|
||||
|
||||
if(job.Transparent)
|
||||
{
|
||||
RenderQueue.Forward.Add(job);
|
||||
@@ -177,7 +182,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void EnqueueBlendMapModel(Model* model, BlendMapTexture textureRed, BlendMapTexture textureGreen, BlendMapTexture textureBlue, float textureRepeat, glm::mat4 modelMatrix)
|
||||
void EnqueueBlendMapModel(Model* model, BlendMapTexture textureRed, BlendMapTexture textureGreen, BlendMapTexture textureBlue, float textureRepeat, glm::mat4 modelMatrix, glm::vec4 color)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
@@ -200,17 +205,19 @@ private:
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
|
||||
RenderQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
|
||||
void EnqueueSprite(Texture* texture, glm::mat4 modelMatrix)
|
||||
void EnqueueSprite(Texture* texture, glm::mat4 modelMatrix, glm::vec4 color)
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
job.Texture = *texture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
+20
-16
@@ -750,14 +750,16 @@ EntityID GameWorld::CreateTank(int playerID)
|
||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
||||
CommitEntity(entity);
|
||||
|
||||
auto particleEntity = CreateEntity(entity);
|
||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
||||
TEMP->Scale = glm::vec3(0);
|
||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
||||
emitterComponent->ParticleTemplate = particleEntity;
|
||||
|
||||
CommitEntity(particleEntity);
|
||||
{
|
||||
auto particleEntity = CreateEntity(entity);
|
||||
auto templateComponent = AddComponent<Components::Template>(particleEntity);
|
||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
||||
TEMP->Scale = glm::vec3(0);
|
||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
||||
CommitEntity(particleEntity);
|
||||
emitterComponent->ParticleTemplate = particleEntity;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -835,14 +837,16 @@ EntityID GameWorld::CreateTank(int playerID)
|
||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
||||
CommitEntity(entity);
|
||||
|
||||
auto particleEntity = CreateEntity(entity);
|
||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
||||
TEMP->Scale = glm::vec3(0);
|
||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
||||
emitterComponent->ParticleTemplate = particleEntity;
|
||||
|
||||
CommitEntity(particleEntity);
|
||||
{
|
||||
auto particleEntity = CreateEntity(entity);
|
||||
auto templateComponent = AddComponent<Components::Template>(particleEntity);
|
||||
auto TEMP = AddComponent<Components::Transform>(particleEntity);
|
||||
TEMP->Scale = glm::vec3(0);
|
||||
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
|
||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
||||
CommitEntity(particleEntity);
|
||||
emitterComponent->ParticleTemplate = particleEntity;
|
||||
}
|
||||
}
|
||||
|
||||
CommitEntity(tank);
|
||||
|
||||
+6
-9
@@ -490,7 +490,7 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
||||
glUniform4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||
glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||
|
||||
glBindVertexArray(modelJob->VAO);
|
||||
|
||||
@@ -514,11 +514,11 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
if (spriteJob)
|
||||
{
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniform4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->Texture);
|
||||
@@ -557,8 +557,6 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
glEnableVertexAttribArray(0);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
|
||||
|
||||
//for (auto tuple : ModelsToRender) //// Todo: Add so it's TransparentModelsToRender
|
||||
//{
|
||||
// Model* model;
|
||||
@@ -589,7 +587,6 @@ void Renderer::Swap()
|
||||
glfwSwapBuffers(m_Window);
|
||||
}
|
||||
|
||||
|
||||
void Renderer::DrawSkybox()
|
||||
{
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
Reference in New Issue
Block a user