No ship shadow
This commit is contained in:
@@ -11,10 +11,11 @@ namespace Components
|
|||||||
|
|
||||||
struct Model : Component
|
struct Model : Component
|
||||||
{
|
{
|
||||||
Model() : Visible(true) { }
|
Model() : Visible(true), ShadowCaster(true) { }
|
||||||
std::string ModelFile;
|
std::string ModelFile;
|
||||||
Color Color;
|
Color Color;
|
||||||
bool Visible;
|
bool Visible;
|
||||||
|
bool ShadowCaster;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ void GameWorld::Initialize()
|
|||||||
transform->Scale = glm::vec3(1.0f);
|
transform->Scale = glm::vec3(1.0f);
|
||||||
model = AddComponent<Components::Model>(m_Player, "Model");
|
model = AddComponent<Components::Model>(m_Player, "Model");
|
||||||
model->ModelFile = "Models/ship.obj";
|
model->ModelFile = "Models/ship.obj";
|
||||||
|
model->ShadowCaster = false;
|
||||||
AddComponent<Components::Input>(m_Player, "Input");
|
AddComponent<Components::Input>(m_Player, "Input");
|
||||||
collision = AddComponent<Components::Collision>(m_Player, "Collision");
|
collision = AddComponent<Components::Collision>(m_Player, "Collision");
|
||||||
collision->Phantom = false;
|
collision->Phantom = false;
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ void Renderer::DrawScene()
|
|||||||
Model* model;
|
Model* model;
|
||||||
glm::mat4 modelMatrix;
|
glm::mat4 modelMatrix;
|
||||||
bool visible;
|
bool visible;
|
||||||
std::tie(model, modelMatrix, visible) = tuple;
|
std::tie(model, modelMatrix, visible, std::ignore) = tuple;
|
||||||
if (!visible)
|
if (!visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -293,8 +293,10 @@ void Renderer::DrawShadowMap()
|
|||||||
{
|
{
|
||||||
Model* model;
|
Model* model;
|
||||||
glm::mat4 modelMatrix;
|
glm::mat4 modelMatrix;
|
||||||
bool visible;
|
bool shadow;
|
||||||
std::tie(model, modelMatrix, visible) = tuple;
|
std::tie(model, modelMatrix, std::ignore, shadow) = tuple;
|
||||||
|
if (!shadow)
|
||||||
|
continue;
|
||||||
|
|
||||||
MVP = depthCamera * modelMatrix;
|
MVP = depthCamera * modelMatrix;
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramShadows.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
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
|
//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);
|
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
||||||
// You can now use ModelMatrix to build the MVP matrix
|
// 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(
|
void Renderer::AddPointLightToDraw(
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
|
|
||||||
int HEIGHT, WIDTH;
|
int HEIGHT, WIDTH;
|
||||||
|
|
||||||
std::list<std::tuple<Model*, glm::mat4, bool>> ModelsToRender;
|
std::list<std::tuple<Model*, glm::mat4, bool, bool>> ModelsToRender;
|
||||||
int Lights;
|
int Lights;
|
||||||
std::vector<float> Light_position;
|
std::vector<float> Light_position;
|
||||||
std::vector<float> Light_specular;
|
std::vector<float> Light_specular;
|
||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
void Draw(double dt);
|
void Draw(double dt);
|
||||||
void DrawText();
|
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 AddTextToDraw();
|
||||||
void AddPointLightToDraw(
|
void AddPointLightToDraw(
|
||||||
glm::vec3 _position,
|
glm::vec3 _position,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
|
|||||||
auto model = m_CachedModels[modelComponent->ModelFile];
|
auto model = m_CachedModels[modelComponent->ModelFile];
|
||||||
glm::vec3 position = m_TransformSystem->AbsolutePosition(entity);
|
glm::vec3 position = m_TransformSystem->AbsolutePosition(entity);
|
||||||
glm::quat orientation = m_TransformSystem->AbsoluteOrientation(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
|
// Debug draw bounds
|
||||||
|
|||||||
Reference in New Issue
Block a user