spriteComponent WIP
This commit is contained in:
@@ -31,6 +31,56 @@ bool RenderSystem::OnSetCamera(Events::SetCamera& e)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
||||
{
|
||||
auto sprites = world->GetComponents("Sprite");
|
||||
if (sprites == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& cSprite : *sprites) {
|
||||
bool visible = cSprite["Visible"];
|
||||
if (!visible) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
EntityWrapper entity(world, cSprite.EntityID);
|
||||
|
||||
// Only render children of a camera if that camera is currently active
|
||||
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string diffuseResource = cSprite["DiffuseTexture"];
|
||||
std::string glowResource = cSprite["GlowMap"];
|
||||
if (diffuseResource.empty() && glowResource.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float fillPercentage = 0.f;
|
||||
glm::vec4 fillColor = glm::vec4(0);
|
||||
if (world->HasComponent(entity.ID, "Fill")) {
|
||||
auto fillComponent = world->GetComponent(entity.ID, "Fill");
|
||||
fillPercentage = (float)(double)fillComponent["Percentage"];
|
||||
fillColor = (glm::vec4)fillComponent["Color"];
|
||||
}
|
||||
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world);
|
||||
//modelMatrix *= m_Camera->BillboardMatrix();
|
||||
|
||||
std::shared_ptr<SpriteJob> spriteJob = std::shared_ptr<SpriteJob>(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage));
|
||||
|
||||
jobs.push_back(spriteJob);
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderSystem::isChildOfACamera(EntityWrapper entity)
|
||||
{
|
||||
return entity.FirstParentWithComponent("Camera").Valid();
|
||||
@@ -167,7 +217,6 @@ void RenderSystem::fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RenderSystem::fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
||||
{
|
||||
auto directionalLights = world->GetComponents("DirectionalLight");
|
||||
@@ -189,7 +238,6 @@ void RenderSystem::fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>&
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
||||
{
|
||||
auto texts = world->GetComponents("Text");
|
||||
@@ -255,6 +303,7 @@ void RenderSystem::Update(double dt)
|
||||
fillPointLights(scene.PointLightJobs, m_World);
|
||||
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
||||
fillText(scene.TextJobs, m_World);
|
||||
fillSprites(scene.SpriteJobs, m_World);
|
||||
m_RenderFrame->Add(scene);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user