diff --git a/Escape-the-Dawn/Components/Model.h b/Escape-the-Dawn/Components/Model.h index dc58640..ad3b4f3 100644 --- a/Escape-the-Dawn/Components/Model.h +++ b/Escape-the-Dawn/Components/Model.h @@ -11,10 +11,11 @@ namespace Components struct Model : Component { - Model() : Visible(true) { } + Model() : Visible(true), ShadowCaster(true) { } std::string ModelFile; Color Color; bool Visible; + bool ShadowCaster; }; } diff --git a/Escape-the-Dawn/GameWorld.cpp b/Escape-the-Dawn/GameWorld.cpp index 495ff02..ce080cc 100644 --- a/Escape-the-Dawn/GameWorld.cpp +++ b/Escape-the-Dawn/GameWorld.cpp @@ -85,6 +85,7 @@ void GameWorld::Initialize() transform->Scale = glm::vec3(1.0f); model = AddComponent(m_Player, "Model"); model->ModelFile = "Models/ship.obj"; + model->ShadowCaster = false; AddComponent(m_Player, "Input"); collision = AddComponent(m_Player, "Collision"); collision->Phantom = false; diff --git a/Escape-the-Dawn/Renderer.cpp b/Escape-the-Dawn/Renderer.cpp index ec03c06..b5fed4d 100644 --- a/Escape-the-Dawn/Renderer.cpp +++ b/Escape-the-Dawn/Renderer.cpp @@ -239,7 +239,7 @@ void Renderer::DrawScene() Model* model; glm::mat4 modelMatrix; bool visible; - std::tie(model, modelMatrix, visible) = tuple; + std::tie(model, modelMatrix, visible, std::ignore) = tuple; if (!visible) continue; @@ -293,8 +293,10 @@ void Renderer::DrawShadowMap() { Model* model; glm::mat4 modelMatrix; - bool visible; - std::tie(model, modelMatrix, visible) = tuple; + bool shadow; + std::tie(model, modelMatrix, std::ignore, shadow) = tuple; + if (!shadow) + continue; MVP = depthCamera * modelMatrix; glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramShadows.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); @@ -355,11 +357,11 @@ void Renderer::AddTextToDraw() //Add to draw shit vector } -void Renderer::AddModelToDraw(std::shared_ptr model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible) +void Renderer::AddModelToDraw(std::shared_ptr model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible, bool shadowCaster) { glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale); // You can now use ModelMatrix to build the MVP matrix - ModelsToRender.push_back(std::make_tuple(model.get(), modelMatrix, visible)); + ModelsToRender.push_back(std::make_tuple(model.get(), modelMatrix, visible, shadowCaster)); } void Renderer::AddPointLightToDraw( diff --git a/Escape-the-Dawn/Renderer.h b/Escape-the-Dawn/Renderer.h index f140c4f..30ac40d 100644 --- a/Escape-the-Dawn/Renderer.h +++ b/Escape-the-Dawn/Renderer.h @@ -26,7 +26,7 @@ public: int HEIGHT, WIDTH; - std::list> ModelsToRender; + std::list> ModelsToRender; int Lights; std::vector Light_position; std::vector Light_specular; @@ -43,7 +43,7 @@ public: void Draw(double dt); void DrawText(); - void AddModelToDraw(std::shared_ptr model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible); + void AddModelToDraw(std::shared_ptr model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible, bool shadowCaster); void AddTextToDraw(); void AddPointLightToDraw( glm::vec3 _position, diff --git a/Escape-the-Dawn/Systems/RenderSystem.cpp b/Escape-the-Dawn/Systems/RenderSystem.cpp index 67827bd..35aff58 100644 --- a/Escape-the-Dawn/Systems/RenderSystem.cpp +++ b/Escape-the-Dawn/Systems/RenderSystem.cpp @@ -27,7 +27,7 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p auto model = m_CachedModels[modelComponent->ModelFile]; glm::vec3 position = m_TransformSystem->AbsolutePosition(entity); glm::quat orientation = m_TransformSystem->AbsoluteOrientation(entity); - m_Renderer->AddModelToDraw(model, position, orientation, transformComponent->Scale, modelComponent->Visible); + m_Renderer->AddModelToDraw(model, position, orientation, transformComponent->Scale, modelComponent->Visible, modelComponent->ShadowCaster); } // Debug draw bounds