From 2e441f33ab3296a3710297b86147fa26540742d9 Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Sun, 12 Apr 2026 21:40:13 +0200 Subject: [PATCH] Idk --- Seele | 2 +- src/CMakeLists.txt | 2 ++ src/FluidSimulationGame.cpp | 37 +++++++++++++------------ src/FluidSimulationGame.h | 2 ++ src/System/CMakeLists.txt | 5 ++++ src/System/FlyCamSystem.cpp | 54 +++++++++++++++++++++++++++++++++++++ src/System/FlyCamSystem.h | 23 ++++++++++++++++ 7 files changed, 107 insertions(+), 18 deletions(-) create mode 100644 src/System/CMakeLists.txt create mode 100644 src/System/FlyCamSystem.cpp create mode 100644 src/System/FlyCamSystem.h diff --git a/Seele b/Seele index ac317a3..495e683 160000 --- a/Seele +++ b/Seele @@ -1 +1 @@ -Subproject commit ac317a3829e5c8a56a683fecc5b59f1e1dc8d990 +Subproject commit 495e683522a6e5034185172a63b90944801d4083 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 245c788..da3446f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,3 +3,5 @@ target_sources(FluidSimulation FluidSimulationGame.cpp FluidSimulationGame.h ) + +add_subdirectory(System/) \ No newline at end of file diff --git a/src/FluidSimulationGame.cpp b/src/FluidSimulationGame.cpp index bd1e2bd..6fd3151 100644 --- a/src/FluidSimulationGame.cpp +++ b/src/FluidSimulationGame.cpp @@ -1,8 +1,11 @@ #include "FluidSimulationGame.h" +#include "Actor/CameraActor.h" #include "Actor/DirectionalLightActor.h" #include "Actor/PointLightActor.h" #include "Actor/StaticMeshActor.h" #include "Asset/AssetRegistry.h" +#include "Component/KeyboardInput.h" +#include "System/FlyCamSystem.h" using namespace Seele; @@ -11,24 +14,24 @@ FluidSimulationGame::FluidSimulationGame() {} FluidSimulationGame::~FluidSimulationGame() {} void FluidSimulationGame::setupScene(Seele::PScene scene, Seele::PSystemGraph graph) { - mesh = new StaticMeshActor(scene, AssetRegistry::findMesh("rttest", "rttest")); - sun = new DirectionalLightActor(scene, Vector(1, -1, 1), 1, Vector(1, 1, 1)); - pointLight = new PointLightActor(scene, Vector(0, 1, 0), 1, Vector(1, 1, 1), 10); + graph->addSystem(new FlyCamSystem(scene)); + mesh = new StaticMeshActor(scene, AssetRegistry::findMesh("rttest", "rttest")); + sun = new DirectionalLightActor(scene, Vector(1, -1, 1), 1, Vector(1, 1, 1)); + pointLight = new PointLightActor(scene, Vector(0, 1, 0), 1, Vector(1, 1, 1), 10); + cam = new CameraActor(scene); + cam->attachComponent(); + cam->getCameraComponent().mainCamera = true; - Seele::Component::Transform transform; - Seele::Component::FluidGrid grid; - grid.cellSize = 0.1f; - grid.viscosity = 0.001f; - grid.diffusion = 0.0001f; - grid.gridSize = {64, 64, 64}; - transform.transform.setPosition({0.0f, 0.0f, 0.0f}); - scene->getFluidScene()->updateFluidData(0, transform, grid); + Seele::Component::Transform transform; + Seele::Component::FluidGrid grid; + grid.cellSize = 0.1f; + grid.viscosity = 0.001f; + grid.diffusion = 0.0001f; + grid.gridSize = {16, 16, 16}; + transform.transform.setPosition({0.0f, 0.0f, 0.0f}); + scene->getFluidScene()->updateFluidData(0, transform, grid); } -extern "C" FluidSimulationGame* createInstance() { - return new FluidSimulationGame(); -} +extern "C" FluidSimulationGame *createInstance() { return new FluidSimulationGame(); } -extern "C" void destroyInstance(FluidSimulationGame* game) { - delete game; -} \ No newline at end of file +extern "C" void destroyInstance(FluidSimulationGame *game) { delete game; } \ No newline at end of file diff --git a/src/FluidSimulationGame.h b/src/FluidSimulationGame.h index c423273..ca7566b 100644 --- a/src/FluidSimulationGame.h +++ b/src/FluidSimulationGame.h @@ -3,6 +3,7 @@ #include "Actor/PointLightActor.h" #include "Actor/StaticMeshActor.h" #include "Game.h" +#include "Graphics/RenderPass/BasePass.h" class FluidSimulationGame : public Seele::Game { public: @@ -13,6 +14,7 @@ private: Seele::OStaticMeshActor mesh; Seele::ODirectionalLightActor sun; Seele::OPointLightActor pointLight; + Seele::OCameraActor cam; }; extern "C" FluidSimulationGame* createInstance(); diff --git a/src/System/CMakeLists.txt b/src/System/CMakeLists.txt new file mode 100644 index 0000000..ef0aab4 --- /dev/null +++ b/src/System/CMakeLists.txt @@ -0,0 +1,5 @@ +target_sources(FluidSimulation + PUBLIC + FlyCamSystem.h + FlyCamSystem.cpp + ) \ No newline at end of file diff --git a/src/System/FlyCamSystem.cpp b/src/System/FlyCamSystem.cpp new file mode 100644 index 0000000..68f7385 --- /dev/null +++ b/src/System/FlyCamSystem.cpp @@ -0,0 +1,54 @@ +#include "FlyCamSystem.h" +#include + +FlyCamSystem::FlyCamSystem(PScene scene) + : System::ComponentSystem(scene) {} + +FlyCamSystem::~FlyCamSystem() {} + +void FlyCamSystem::update(Component::KeyboardInput& input, Component::Camera& camera, Component::Transform& transform) { + float cameraMove = static_cast(deltaTime) * 4; + if(input.keys[KeyCode::KEY_LEFT_SHIFT]) + { + cameraMove *= 10; + } + Vector forward = transform.getForward(); + Vector side = transform.getRight(); + Vector moveVector = Vector(); + + if (input.keys[KeyCode::KEY_J]) + { + std::cout << transform.getPosition() << std::endl; + } + + if(input.keys[KeyCode::KEY_W]) + { + moveVector += forward * cameraMove; + } + if(input.keys[KeyCode::KEY_S]) + { + moveVector += forward * -cameraMove; + } + if(input.keys[KeyCode::KEY_A]) + { + moveVector += side * cameraMove; + } + if(input.keys[KeyCode::KEY_D]) + { + moveVector += side * -cameraMove; + } + if(input.keys[KeyCode::KEY_E]) + { + moveVector += Vector(0, cameraMove, 0); + } + if(input.keys[KeyCode::KEY_Q]) + { + moveVector += Vector(0, -cameraMove, 0); + } + transform.translate(moveVector); + if(input.mouse2) + { + transform.setRotation(glm::rotate(transform.getRotation(), input.deltaX / 500, Vector(0, 1, 0))); + transform.setRotation(glm::rotate(transform.getRotation(), -input.deltaY / 500, transform.getRight())); + } +} \ No newline at end of file diff --git a/src/System/FlyCamSystem.h b/src/System/FlyCamSystem.h new file mode 100644 index 0000000..56f9920 --- /dev/null +++ b/src/System/FlyCamSystem.h @@ -0,0 +1,23 @@ +#pragma once +#include +#include +#include +#include +#include + +using namespace Seele; + +class FlyCamSystem : public System::ComponentSystem< + Component::KeyboardInput, + Component::Camera, + Component::Transform> +{ +public: + FlyCamSystem(PScene scene); + virtual ~FlyCamSystem(); + virtual void update(Component::KeyboardInput& input, Component::Camera& camera, Component::Transform& transform) override; +private: + float lastMouseX; + float lastMouseY; +}; +DEFINE_REF(FlyCamSystem) \ No newline at end of file