Idk
This commit is contained in:
+1
-1
Submodule Seele updated: ac317a3829...495e683522
@@ -3,3 +3,5 @@ target_sources(FluidSimulation
|
||||
FluidSimulationGame.cpp
|
||||
FluidSimulationGame.h
|
||||
)
|
||||
|
||||
add_subdirectory(System/)
|
||||
@@ -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) {
|
||||
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<Component::KeyboardInput>();
|
||||
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};
|
||||
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;
|
||||
}
|
||||
extern "C" void destroyInstance(FluidSimulationGame *game) { delete game; }
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
target_sources(FluidSimulation
|
||||
PUBLIC
|
||||
FlyCamSystem.h
|
||||
FlyCamSystem.cpp
|
||||
)
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "FlyCamSystem.h"
|
||||
#include <iostream>
|
||||
|
||||
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();
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include <MinimalEngine.h>
|
||||
#include <Scene/Scene.h>
|
||||
#include <System/ComponentSystem.h>
|
||||
#include <Component/Camera.h>
|
||||
#include <Component/KeyboardInput.h>
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user