More changes
This commit is contained in:
@@ -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<Component::KeyboardInput>();
|
||||
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<Component::FluidGrid>();
|
||||
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(); }
|
||||
|
||||
@@ -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();
|
||||
|
||||
+52
-45
@@ -1,54 +1,61 @@
|
||||
#include "FlyCamSystem.h"
|
||||
#include "Component/FluidGrid.h"
|
||||
#include "Scene/FluidScene.h"
|
||||
#include <iostream>
|
||||
|
||||
FlyCamSystem::FlyCamSystem(PScene scene)
|
||||
: System::ComponentSystem<Component::KeyboardInput, Component::Camera, Component::Transform>(scene) {}
|
||||
FlyCamSystem::FlyCamSystem(PScene scene) : System::ComponentSystem<Component::KeyboardInput, Component::Camera, Component::Transform>(scene) {}
|
||||
|
||||
FlyCamSystem::~FlyCamSystem() {}
|
||||
|
||||
void FlyCamSystem::update(Component::KeyboardInput& input, Component::Camera& camera, Component::Transform& transform) {
|
||||
float cameraMove = static_cast<float>(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<float>(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>([](Component::FluidGrid &grid) {
|
||||
grid.paused = true;
|
||||
});
|
||||
}
|
||||
if (input.keys[KeyCode::KEY_N]) {
|
||||
scene->view<Component::FluidGrid>([](Component::FluidGrid &grid) {
|
||||
grid.paused = false;
|
||||
});
|
||||
}
|
||||
if (input.keys[KeyCode::KEY_F]) {
|
||||
scene->getFluidScene()->addSource();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user