|
|
|
@ -2,20 +2,53 @@
|
|
|
|
|
#include "inferno/scene/components.h" |
|
|
|
|
#include "inferno/scene/entity.h" |
|
|
|
|
#include "inferno/scene/scene.h" |
|
|
|
|
#include "inferno/systems/camera.h" |
|
|
|
|
#include "inferno/systems/transform.h" |
|
|
|
|
|
|
|
|
|
namespace Inferno { |
|
|
|
|
|
|
|
|
|
Scene::Scene() |
|
|
|
|
{ |
|
|
|
|
initialize(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Scene::~Scene() |
|
|
|
|
{ |
|
|
|
|
destroy(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Scene::initialize() |
|
|
|
|
{ |
|
|
|
|
m_registry = std::make_shared<entt::registry>(); |
|
|
|
|
|
|
|
|
|
Entity entity = createEntity("Test Entity"); |
|
|
|
|
TransformSystem* transformSystem = new TransformSystem(); |
|
|
|
|
transformSystem->initialize(); |
|
|
|
|
TransformSystem::the().setRegistry(m_registry); |
|
|
|
|
|
|
|
|
|
CameraSystem* cameraSystem = new CameraSystem(); |
|
|
|
|
cameraSystem->initialize(); |
|
|
|
|
CameraSystem::the().setRegistry(m_registry); |
|
|
|
|
|
|
|
|
|
dbg() << entity.get<TagComponent>(); |
|
|
|
|
Entity camera = createEntity("Camera Entity"); |
|
|
|
|
camera.add<PerspectiveCameraComponent>(); |
|
|
|
|
auto& cameraTransform = camera.get<TransformComponent>(); |
|
|
|
|
cameraTransform.translate = { 0.0f, 0.0f, 1.0f }; |
|
|
|
|
cameraTransform.rotate = { 0.0f, 0.0f, -1.0f }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Scene::update(float deltaTime) |
|
|
|
|
{ |
|
|
|
|
TransformSystem::the().update(); |
|
|
|
|
CameraSystem::the().update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (entity) { |
|
|
|
|
dbg() << "Entity is valid"; |
|
|
|
|
void Scene::render() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Scene::destroy() |
|
|
|
|
{ |
|
|
|
|
TransformSystem::the().destroy(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Entity Scene::createEntity(const std::string& name) |
|
|
|
@ -37,4 +70,15 @@ namespace Inferno {
|
|
|
|
|
return Entity(m_registry, handle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
glm::mat4 Scene::cameraProjectionView() |
|
|
|
|
{ |
|
|
|
|
auto view = m_registry->view<TransformComponent, PerspectiveCameraComponent>(); |
|
|
|
|
|
|
|
|
|
for(auto&& [entity, transform, perspective] : view.each()) { |
|
|
|
|
return perspective.projection * transform.transform; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return glm::mat4 { 1.0f }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|