Graphics: Set default render mask for LightComponent and GraphicsComponent

This commit is contained in:
SirLynix 2023-01-29 11:38:08 +01:00
parent 4a91f3d470
commit 3f200edeb6
5 changed files with 18 additions and 20 deletions

View File

@ -155,7 +155,7 @@ int main()
//bobNode.SetScale(1.f / 40.f * 0.5f); //bobNode.SetScale(1.f / 40.f * 0.5f);
auto& bobGfx = registry.emplace<Nz::GraphicsComponent>(bobEntity); auto& bobGfx = registry.emplace<Nz::GraphicsComponent>(bobEntity);
bobGfx.AttachRenderable(bobModel, 0xFFFFFFFF); bobGfx.AttachRenderable(bobModel);
} }
}*/ }*/
@ -168,7 +168,7 @@ int main()
auto& cameraLight = lightEntity1.emplace<Nz::LightComponent>(); auto& cameraLight = lightEntity1.emplace<Nz::LightComponent>();
auto& spotLight = cameraLight.AddLight<Nz::SpotLight>(0xFFFFFFFF); auto& spotLight = cameraLight.AddLight<Nz::SpotLight>();
spotLight.UpdateColor(Nz::Color::Red()); spotLight.UpdateColor(Nz::Color::Red());
spotLight.UpdateInnerAngle(Nz::DegreeAnglef(15.f)); spotLight.UpdateInnerAngle(Nz::DegreeAnglef(15.f));
spotLight.UpdateOuterAngle(Nz::DegreeAnglef(20.f)); spotLight.UpdateOuterAngle(Nz::DegreeAnglef(20.f));
@ -183,7 +183,7 @@ int main()
auto& cameraLight = lightEntity2.emplace<Nz::LightComponent>(); auto& cameraLight = lightEntity2.emplace<Nz::LightComponent>();
auto& spotLight = cameraLight.AddLight<Nz::SpotLight>(0xFFFFFFFF); auto& spotLight = cameraLight.AddLight<Nz::SpotLight>();
spotLight.UpdateColor(Nz::Color::Green()); spotLight.UpdateColor(Nz::Color::Green());
spotLight.EnableShadowCasting(true); spotLight.EnableShadowCasting(true);
spotLight.UpdateShadowMapSize(1024); spotLight.UpdateShadowMapSize(1024);
@ -198,7 +198,7 @@ int main()
//bobNode.SetPosition(Nz::Vector3f(0.f, -1.f, 0.f)); //bobNode.SetPosition(Nz::Vector3f(0.f, -1.f, 0.f));
auto& bobGfx = bobEntity.emplace<Nz::GraphicsComponent>(); auto& bobGfx = bobEntity.emplace<Nz::GraphicsComponent>();
bobGfx.AttachRenderable(bobModel, 0xFFFFFFFF); bobGfx.AttachRenderable(bobModel);
auto& sharedSkeleton = bobEntity.emplace<Nz::SharedSkeletonComponent>(skeleton); auto& sharedSkeleton = bobEntity.emplace<Nz::SharedSkeletonComponent>(skeleton);
@ -232,7 +232,7 @@ int main()
sphereBody.SetGeom(std::make_shared<Nz::SphereCollider3D>(0.1f)); sphereBody.SetGeom(std::make_shared<Nz::SphereCollider3D>(0.1f));
auto& sphereGfx = sphereEntity.emplace<Nz::GraphicsComponent>(); auto& sphereGfx = sphereEntity.emplace<Nz::GraphicsComponent>();
sphereGfx.AttachRenderable(sphereModel, 0xFFFFFFFF); sphereGfx.AttachRenderable(sphereModel);
} }
entt::handle smallBobEntity = world.CreateEntity(); entt::handle smallBobEntity = world.CreateEntity();
@ -240,7 +240,7 @@ int main()
smallBobNode.SetParentJoint(bobEntity, "LeftHand"); smallBobNode.SetParentJoint(bobEntity, "LeftHand");
auto& smallBobGfx = smallBobEntity.emplace<Nz::GraphicsComponent>(); auto& smallBobGfx = smallBobEntity.emplace<Nz::GraphicsComponent>();
smallBobGfx.AttachRenderable(bobModel, 0xFFFFFFFF); smallBobGfx.AttachRenderable(bobModel);
smallBobEntity.emplace<Nz::SharedSkeletonComponent>(skeleton); smallBobEntity.emplace<Nz::SharedSkeletonComponent>(skeleton);
@ -253,7 +253,7 @@ int main()
auto& cameraLight = lightEntity3.emplace<Nz::LightComponent>(); auto& cameraLight = lightEntity3.emplace<Nz::LightComponent>();
auto& pointLight = cameraLight.AddLight<Nz::PointLight>(0xFFFFFFFF); auto& pointLight = cameraLight.AddLight<Nz::PointLight>();
pointLight.UpdateColor(Nz::Color::Blue()); pointLight.UpdateColor(Nz::Color::Blue());
pointLight.UpdateRadius(3.f); pointLight.UpdateRadius(3.f);
pointLight.EnableShadowCasting(true); pointLight.EnableShadowCasting(true);
@ -329,7 +329,7 @@ int main()
planeModel->SetMaterial(0, planeMat); planeModel->SetMaterial(0, planeMat);
auto& planeGfx = planeEntity.emplace<Nz::GraphicsComponent>(); auto& planeGfx = planeEntity.emplace<Nz::GraphicsComponent>();
planeGfx.AttachRenderable(planeModel, 0xFFFFFFFF); planeGfx.AttachRenderable(planeModel);
planeEntity.emplace<Nz::NodeComponent>(); planeEntity.emplace<Nz::NodeComponent>();
@ -348,7 +348,7 @@ int main()
entt::handle boxEntity = world.CreateEntity(); entt::handle boxEntity = world.CreateEntity();
boxEntity.emplace<Nz::NodeComponent>().SetPosition(Nz::Vector3f(0.f, 0.25f, -0.5f)); boxEntity.emplace<Nz::NodeComponent>().SetPosition(Nz::Vector3f(0.f, 0.25f, -0.5f));
boxEntity.emplace<Nz::GraphicsComponent>().AttachRenderable(boxModel, 0xFFFFFFFF); boxEntity.emplace<Nz::GraphicsComponent>().AttachRenderable(boxModel);
} }
Nz::MillisecondClock fpsClock, updateClock; Nz::MillisecondClock fpsClock, updateClock;

View File

@ -17,16 +17,14 @@ int main()
auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>(); auto& ecs = app.AddComponent<Nz::AppEntitySystemComponent>();
auto& world = ecs.AddWorld<Nz::EnttWorld>(); auto& world = ecs.AddWorld<Nz::EnttWorld>();
Nz::RenderSystem& renderSystem = world.AddSystem<Nz::RenderSystem>(); auto& renderSystem = world.AddSystem<Nz::RenderSystem>();
auto& windowSwapchain = renderSystem.CreateSwapchain(mainWindow); Nz::WindowSwapchain& windowSwapchain = renderSystem.CreateSwapchain(mainWindow);
entt::handle cameraEntity = world.CreateEntity(); entt::handle cameraEntity = world.CreateEntity();
{ cameraEntity.emplace<Nz::NodeComponent>();
cameraEntity.emplace<Nz::NodeComponent>();
auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(&windowSwapchain, Nz::ProjectionType::Orthographic); auto& cameraComponent = cameraEntity.emplace<Nz::CameraComponent>(&windowSwapchain, Nz::ProjectionType::Orthographic);
cameraComponent.UpdateClearColor(Nz::Color(0.46f, 0.48f, 0.84f, 1.f)); cameraComponent.UpdateClearColor(Nz::Color(0.f, 0.f, 0.f, 1.f));
}
Nz::SimpleTextDrawer textDrawer; Nz::SimpleTextDrawer textDrawer;
textDrawer.SetCharacterSize(72); textDrawer.SetCharacterSize(72);
@ -40,7 +38,7 @@ int main()
{ {
auto& nodeComponent = textEntity.emplace<Nz::NodeComponent>(); auto& nodeComponent = textEntity.emplace<Nz::NodeComponent>();
auto& gfxComponent = textEntity.emplace<Nz::GraphicsComponent>(); auto& gfxComponent = textEntity.emplace<Nz::GraphicsComponent>();
gfxComponent.AttachRenderable(textSprite, 0xFFFFFFFF); gfxComponent.AttachRenderable(textSprite);
Nz::Boxf textBox = textSprite->GetAABB(); Nz::Boxf textBox = textSprite->GetAABB();
Nz::Vector2ui windowSize = mainWindow.GetSize(); Nz::Vector2ui windowSize = mainWindow.GetSize();

View File

@ -40,7 +40,7 @@ int main()
{ {
auto& nodeComponent = textEntity.emplace<Nz::NodeComponent>(); auto& nodeComponent = textEntity.emplace<Nz::NodeComponent>();
auto& gfxComponent = textEntity.emplace<Nz::GraphicsComponent>(); auto& gfxComponent = textEntity.emplace<Nz::GraphicsComponent>();
gfxComponent.AttachRenderable(textSprite, 0xFFFFFFFF); gfxComponent.AttachRenderable(textSprite);
Nz::Boxf textBox = textSprite->GetAABB(); Nz::Boxf textBox = textSprite->GetAABB();
Nz::Vector2ui windowSize = mainWindow.GetSize(); Nz::Vector2ui windowSize = mainWindow.GetSize();

View File

@ -28,7 +28,7 @@ namespace Nz
GraphicsComponent(GraphicsComponent&&) = default; GraphicsComponent(GraphicsComponent&&) = default;
~GraphicsComponent() = default; ~GraphicsComponent() = default;
inline void AttachRenderable(std::shared_ptr<InstancedRenderable> renderable, UInt32 renderMask); inline void AttachRenderable(std::shared_ptr<InstancedRenderable> renderable, UInt32 renderMask = 0xFFFFFFFF);
inline void Clear(); inline void Clear();

View File

@ -28,7 +28,7 @@ namespace Nz
LightComponent(LightComponent&&) = default; LightComponent(LightComponent&&) = default;
~LightComponent() = default; ~LightComponent() = default;
template<typename T, typename... Args> T& AddLight(UInt32 renderMask, Args&&... args); template<typename T, typename... Args> T& AddLight(UInt32 renderMask = 0xFFFFFFFF, Args&&... args);
inline void Clear(); inline void Clear();