#include "scene.h" #include "components/name.h" #include "components/transform.h" #include "core/camera.h" #include "core/graphics/mesh.h" #include "core/light.h" #include "window/Window.h" Scene::Scene(entt::registry registry) : m_registry(std::move(registry)) { auto mesh_view = m_registry.view>(); for (auto [entity, mesh] : mesh_view.each()) { m_registry.emplace(entity, GpuMesh(mesh)); // Remove Mesh resource as it is no longer needed. m_registry.erase>(entity); } auto material_view = m_registry.view>(); for (auto [entity, material] : material_view.each()) { m_registry.emplace(entity, GpuMaterial(material)); // Remove Material resource as it is no longer needed. m_registry.erase>(entity); } // Spawn default lights auto directional_light = m_registry.create(); m_registry.emplace(directional_light, "Directional Light"); m_registry.emplace( directional_light, Transform{.orientation = glm::toQuat( glm::lookAt({}, DirectionalLight::DEFAULT_DIRECTION, Camera::UP_VECTOR))}); m_registry.emplace(directional_light, GlobalTransform{}); m_registry.emplace( directional_light, DirectionalLight{.illuminance = DirectionalLight::DEFAULT_ILLUMINANCE}); auto point_light = m_registry.create(); m_registry.emplace(point_light, "Point Light"); m_registry.emplace(point_light, Transform{.translation = PointLight::DEFAULT_POSITION}); m_registry.emplace(point_light, GlobalTransform{}); m_registry.emplace(point_light, PointLight{.intensity = PointLight::DEFAULT_INTENSITY}); } void Scene::update() { GlobalTransform::update(m_registry); Camera::aspect_ratio_update(m_registry); Camera::keyboard_movement(m_registry); if (m_registry.ctx().get().catched) { Camera::mouse_orientation(m_registry); } }