stuff
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <sophia/handles.hpp>
|
||||
#include <string>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <entt/entt.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace sophia {
|
||||
|
||||
@@ -12,7 +13,11 @@ 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; }
|
||||
|
||||
|
||||
@@ -24,6 +24,13 @@ void SceneRenderer::render(const Scene& scene, Entity camera,
|
||||
|
||||
auto& registry = scene.registry;
|
||||
|
||||
auto view = registry.view<MeshComponent, TransformComponent>();
|
||||
|
||||
for (auto entity : view) {
|
||||
auto& transform = view.get<TransformComponent>(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
|
||||
|
||||
Reference in New Issue
Block a user