From 97267f1a266835888657764ba866a7d61ca19f0d Mon Sep 17 00:00:00 2001 From: Caleb Burke Date: Thu, 24 Sep 2026 05:31:38 +0000 Subject: [PATCH] stuff --- engine/include/sophia/components.hpp | 16 ++++++++++++++++ engine/include/sophia/scene.hpp | 9 +++++++-- engine/src/rendering/scene_renderer.cpp | 7 +++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/engine/include/sophia/components.hpp b/engine/include/sophia/components.hpp index 979c929..a67b198 100644 --- a/engine/include/sophia/components.hpp +++ b/engine/include/sophia/components.hpp @@ -1,5 +1,7 @@ #pragma once +#include +#include #include #include @@ -28,6 +30,20 @@ struct TransformComponent { glm::mat3 normalMatrix() const { return glm::mat3{glm::transpose(glm::inverse(mat4()))}; } + + friend std::ostream& operator<<(std::ostream& os, + const TransformComponent& transform) { + os << "TransformComponent {\n" + << " Position: (" << transform.position.x << ", " + << transform.position.y << ", " << transform.position.z << ")\n" + << " Rotation (w, x, y, z): (" << transform.rotation.w << ", " + << transform.rotation.x << ", " << transform.rotation.y << ", " + << transform.rotation.z << ")\n" + << " Scale: (" << transform.scale.x << ", " << transform.scale.y << ", " + << transform.scale.z << ")\n" + << "}"; + return os; + } }; struct MeshComponent { diff --git a/engine/include/sophia/scene.hpp b/engine/include/sophia/scene.hpp index d23850e..687b50a 100644 --- a/engine/include/sophia/scene.hpp +++ b/engine/include/sophia/scene.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace sophia { @@ -12,13 +13,17 @@ class Scene { Scene(); ~Scene(); - // The camera a render request uses when it doesn't name one. Null until set. + void createEntity(const std::string& name = {}); + void destroyEntity(Entity entity); + + // The camera a render request uses when it doesn't name one. Null until + // set. entt::entity getActiveCamera() const { return activeCamera; } void setActiveCamera(entt::entity camera) { activeCamera = camera; } private: friend class Entity; - friend class SceneRenderer; // !TEMP remove this + friend class SceneRenderer; // !TEMP remove this entt::registry registry; entt::entity activeCamera = entt::null; diff --git a/engine/src/rendering/scene_renderer.cpp b/engine/src/rendering/scene_renderer.cpp index 3b32ab3..dea107d 100644 --- a/engine/src/rendering/scene_renderer.cpp +++ b/engine/src/rendering/scene_renderer.cpp @@ -24,6 +24,13 @@ void SceneRenderer::render(const Scene& scene, Entity camera, auto& registry = scene.registry; + auto view = registry.view(); + + for (auto entity : view) { + auto& transform = view.get(entity); + log::info(transform); + } + // Get all mesh // For each mesh, get all entities(ES) that have a transform and that mesh // For e in ES: add e's transform component to a list