No ship shadow
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ void GameWorld::Initialize()
|
||||
transform->Scale = glm::vec3(1.0f);
|
||||
model = AddComponent<Components::Model>(m_Player, "Model");
|
||||
model->ModelFile = "Models/ship.obj";
|
||||
model->ShadowCaster = false;
|
||||
AddComponent<Components::Input>(m_Player, "Input");
|
||||
collision = AddComponent<Components::Collision>(m_Player, "Collision");
|
||||
collision->Phantom = false;
|
||||
|
||||
@@ -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> model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible)
|
||||
void Renderer::AddModelToDraw(std::shared_ptr<Model> 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(
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
int HEIGHT, WIDTH;
|
||||
|
||||
std::list<std::tuple<Model*, glm::mat4, bool>> ModelsToRender;
|
||||
std::list<std::tuple<Model*, glm::mat4, bool, bool>> ModelsToRender;
|
||||
int Lights;
|
||||
std::vector<float> Light_position;
|
||||
std::vector<float> Light_specular;
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
void Draw(double dt);
|
||||
void DrawText();
|
||||
|
||||
void AddModelToDraw(std::shared_ptr<Model> model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible);
|
||||
void AddModelToDraw(std::shared_ptr<Model> model, glm::vec3 position, glm::quat orientation, glm::vec3 scale, bool visible, bool shadowCaster);
|
||||
void AddTextToDraw();
|
||||
void AddPointLightToDraw(
|
||||
glm::vec3 _position,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user