More changes
This commit is contained in:
+1
-1
Submodule Seele updated: 495e683522...424dea0012
@@ -4,6 +4,7 @@
|
|||||||
#include "Actor/PointLightActor.h"
|
#include "Actor/PointLightActor.h"
|
||||||
#include "Actor/StaticMeshActor.h"
|
#include "Actor/StaticMeshActor.h"
|
||||||
#include "Asset/AssetRegistry.h"
|
#include "Asset/AssetRegistry.h"
|
||||||
|
#include "Component/FluidGrid.h"
|
||||||
#include "Component/KeyboardInput.h"
|
#include "Component/KeyboardInput.h"
|
||||||
#include "System/FlyCamSystem.h"
|
#include "System/FlyCamSystem.h"
|
||||||
|
|
||||||
@@ -16,20 +17,21 @@ FluidSimulationGame::~FluidSimulationGame() {}
|
|||||||
void FluidSimulationGame::setupScene(Seele::PScene scene, Seele::PSystemGraph graph) {
|
void FluidSimulationGame::setupScene(Seele::PScene scene, Seele::PSystemGraph graph) {
|
||||||
graph->addSystem(new FlyCamSystem(scene));
|
graph->addSystem(new FlyCamSystem(scene));
|
||||||
mesh = new StaticMeshActor(scene, AssetRegistry::findMesh("rttest", "rttest"));
|
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);
|
pointLight = new PointLightActor(scene, Vector(0, 1, 0), 1, Vector(1, 1, 1), 10);
|
||||||
cam = new CameraActor(scene);
|
cam = new CameraActor(scene);
|
||||||
cam->attachComponent<Component::KeyboardInput>();
|
cam->attachComponent<Component::KeyboardInput>();
|
||||||
cam->getCameraComponent().mainCamera = true;
|
cam->getCameraComponent().mainCamera = true;
|
||||||
|
fluidActor = new Actor(scene);
|
||||||
|
fluidActor->getTransform().setScale(Vector(20, 20, 20));
|
||||||
|
|
||||||
Seele::Component::Transform transform;
|
auto& grid = fluidActor->attachComponent<Component::FluidGrid>();
|
||||||
Seele::Component::FluidGrid grid;
|
grid.viscosity = 0.1f;
|
||||||
grid.cellSize = 0.1f;
|
grid.diffusion = 0.1f;
|
||||||
grid.viscosity = 0.001f;
|
grid.gridSize = {256, 256, 256};
|
||||||
grid.diffusion = 0.0001f;
|
grid.enableGravity = true;
|
||||||
grid.gridSize = {16, 16, 16};
|
grid.gravity = Vector(10, 0, 0);
|
||||||
transform.transform.setPosition({0.0f, 0.0f, 0.0f});
|
// grid.enableGravity = false;
|
||||||
scene->getFluidScene()->updateFluidData(0, transform, grid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" FluidSimulationGame *createInstance() { return new FluidSimulationGame(); }
|
extern "C" FluidSimulationGame *createInstance() { return new FluidSimulationGame(); }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Actor/Actor.h"
|
||||||
#include "Actor/DirectionalLightActor.h"
|
#include "Actor/DirectionalLightActor.h"
|
||||||
#include "Actor/PointLightActor.h"
|
#include "Actor/PointLightActor.h"
|
||||||
#include "Actor/StaticMeshActor.h"
|
#include "Actor/StaticMeshActor.h"
|
||||||
@@ -15,6 +16,7 @@ private:
|
|||||||
Seele::ODirectionalLightActor sun;
|
Seele::ODirectionalLightActor sun;
|
||||||
Seele::OPointLightActor pointLight;
|
Seele::OPointLightActor pointLight;
|
||||||
Seele::OCameraActor cam;
|
Seele::OCameraActor cam;
|
||||||
|
Seele::OActor fluidActor;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" FluidSimulationGame* createInstance();
|
extern "C" FluidSimulationGame* createInstance();
|
||||||
|
|||||||
+27
-20
@@ -1,54 +1,61 @@
|
|||||||
#include "FlyCamSystem.h"
|
#include "FlyCamSystem.h"
|
||||||
|
#include "Component/FluidGrid.h"
|
||||||
|
#include "Scene/FluidScene.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
FlyCamSystem::FlyCamSystem(PScene scene)
|
FlyCamSystem::FlyCamSystem(PScene scene) : System::ComponentSystem<Component::KeyboardInput, Component::Camera, Component::Transform>(scene) {}
|
||||||
: System::ComponentSystem<Component::KeyboardInput, Component::Camera, Component::Transform>(scene) {}
|
|
||||||
|
|
||||||
FlyCamSystem::~FlyCamSystem() {}
|
FlyCamSystem::~FlyCamSystem() {}
|
||||||
|
|
||||||
void FlyCamSystem::update(Component::KeyboardInput &input, Component::Camera &camera, Component::Transform &transform) {
|
void FlyCamSystem::update(Component::KeyboardInput &input, Component::Camera &camera, Component::Transform &transform) {
|
||||||
float cameraMove = static_cast<float>(deltaTime) * 4;
|
float cameraMove = static_cast<float>(deltaTime) * 4;
|
||||||
if(input.keys[KeyCode::KEY_LEFT_SHIFT])
|
if (input.keys[KeyCode::KEY_LEFT_SHIFT]) {
|
||||||
{
|
|
||||||
cameraMove *= 10;
|
cameraMove *= 10;
|
||||||
}
|
}
|
||||||
Vector forward = transform.getForward();
|
Vector forward = transform.getForward();
|
||||||
Vector side = transform.getRight();
|
Vector side = transform.getRight();
|
||||||
Vector moveVector = Vector();
|
Vector moveVector = Vector();
|
||||||
|
|
||||||
if (input.keys[KeyCode::KEY_J])
|
if (input.keys[KeyCode::KEY_J]) {
|
||||||
{
|
|
||||||
std::cout << transform.getPosition() << std::endl;
|
std::cout << transform.getPosition() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(input.keys[KeyCode::KEY_W])
|
if (input.keys[KeyCode::KEY_W]) {
|
||||||
{
|
|
||||||
moveVector += forward * cameraMove;
|
moveVector += forward * cameraMove;
|
||||||
}
|
}
|
||||||
if(input.keys[KeyCode::KEY_S])
|
if (input.keys[KeyCode::KEY_S]) {
|
||||||
{
|
|
||||||
moveVector += forward * -cameraMove;
|
moveVector += forward * -cameraMove;
|
||||||
}
|
}
|
||||||
if(input.keys[KeyCode::KEY_A])
|
if (input.keys[KeyCode::KEY_A]) {
|
||||||
{
|
|
||||||
moveVector += side * cameraMove;
|
moveVector += side * cameraMove;
|
||||||
}
|
}
|
||||||
if(input.keys[KeyCode::KEY_D])
|
if (input.keys[KeyCode::KEY_D]) {
|
||||||
{
|
|
||||||
moveVector += side * -cameraMove;
|
moveVector += side * -cameraMove;
|
||||||
}
|
}
|
||||||
if(input.keys[KeyCode::KEY_E])
|
if (input.keys[KeyCode::KEY_E]) {
|
||||||
{
|
|
||||||
moveVector += Vector(0, cameraMove, 0);
|
moveVector += Vector(0, cameraMove, 0);
|
||||||
}
|
}
|
||||||
if(input.keys[KeyCode::KEY_Q])
|
if (input.keys[KeyCode::KEY_Q]) {
|
||||||
{
|
|
||||||
moveVector += Vector(0, -cameraMove, 0);
|
moveVector += Vector(0, -cameraMove, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
transform.translate(moveVector);
|
transform.translate(moveVector);
|
||||||
if(input.mouse2)
|
if (input.mouse2) {
|
||||||
{
|
|
||||||
transform.setRotation(glm::rotate(transform.getRotation(), input.deltaX / 500, Vector(0, 1, 0)));
|
transform.setRotation(glm::rotate(transform.getRotation(), input.deltaX / 500, Vector(0, 1, 0)));
|
||||||
transform.setRotation(glm::rotate(transform.getRotation(), -input.deltaY / 500, transform.getRight()));
|
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