diff --git a/Seele b/Seele index 495e683..424dea0 160000 --- a/Seele +++ b/Seele @@ -1 +1 @@ -Subproject commit 495e683522a6e5034185172a63b90944801d4083 +Subproject commit 424dea0012efd70f26f09d1601c72f7cdf23c498 diff --git a/src/FluidSimulationGame.cpp b/src/FluidSimulationGame.cpp index 6fd3151..1f86868 100644 --- a/src/FluidSimulationGame.cpp +++ b/src/FluidSimulationGame.cpp @@ -4,6 +4,7 @@ #include "Actor/PointLightActor.h" #include "Actor/StaticMeshActor.h" #include "Asset/AssetRegistry.h" +#include "Component/FluidGrid.h" #include "Component/KeyboardInput.h" #include "System/FlyCamSystem.h" @@ -16,20 +17,21 @@ FluidSimulationGame::~FluidSimulationGame() {} void FluidSimulationGame::setupScene(Seele::PScene scene, Seele::PSystemGraph graph) { 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)); + 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; + fluidActor = new Actor(scene); + fluidActor->getTransform().setScale(Vector(20, 20, 20)); - 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); + auto& grid = fluidActor->attachComponent(); + grid.viscosity = 0.1f; + grid.diffusion = 0.1f; + grid.gridSize = {256, 256, 256}; + grid.enableGravity = true; + grid.gravity = Vector(10, 0, 0); + // grid.enableGravity = false; } extern "C" FluidSimulationGame *createInstance() { return new FluidSimulationGame(); } diff --git a/src/FluidSimulationGame.h b/src/FluidSimulationGame.h index ca7566b..9e8207b 100644 --- a/src/FluidSimulationGame.h +++ b/src/FluidSimulationGame.h @@ -1,4 +1,5 @@ #pragma once +#include "Actor/Actor.h" #include "Actor/DirectionalLightActor.h" #include "Actor/PointLightActor.h" #include "Actor/StaticMeshActor.h" @@ -15,6 +16,7 @@ private: Seele::ODirectionalLightActor sun; Seele::OPointLightActor pointLight; Seele::OCameraActor cam; + Seele::OActor fluidActor; }; extern "C" FluidSimulationGame* createInstance(); diff --git a/src/System/FlyCamSystem.cpp b/src/System/FlyCamSystem.cpp index 68f7385..0f7be9a 100644 --- a/src/System/FlyCamSystem.cpp +++ b/src/System/FlyCamSystem.cpp @@ -1,54 +1,61 @@ #include "FlyCamSystem.h" +#include "Component/FluidGrid.h" +#include "Scene/FluidScene.h" #include -FlyCamSystem::FlyCamSystem(PScene scene) - : System::ComponentSystem(scene) {} +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(); +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_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())); - } + 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())); + } + if (input.keys[KeyCode::KEY_M]) { + scene->view([](Component::FluidGrid &grid) { + grid.paused = true; + }); + } + if (input.keys[KeyCode::KEY_N]) { + scene->view([](Component::FluidGrid &grid) { + grid.paused = false; + }); + } + if (input.keys[KeyCode::KEY_F]) { + scene->getFluidScene()->addSource(); + } } \ No newline at end of file