Implemented basic game dll interaction
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
target_sources(Editor
|
||||
PRIVATE
|
||||
GameView.h
|
||||
GameView.cpp
|
||||
InspectorView.h
|
||||
InspectorView.cpp
|
||||
SceneView.h
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
#include "GameView.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Window/Window.h"
|
||||
#include "Component/KeyboardInput.h"
|
||||
#include "Actor/CameraActor.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
GameView::GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo)
|
||||
: View(graphics, window, createInfo, "Game")
|
||||
, gameInterface("C:\\Users\\Dynamitos\\TrackClear\\bin\\TrackCleard.dll")
|
||||
, renderGraph(RenderGraphBuilder::build(
|
||||
DepthPrepass(graphics),
|
||||
LightCullingPass(graphics),
|
||||
BasePass(graphics),
|
||||
#ifdef EDITOR
|
||||
DebugPass(graphics),
|
||||
#endif
|
||||
SkyboxRenderPass(graphics)
|
||||
))
|
||||
{
|
||||
scene = new Scene(graphics);
|
||||
systemGraph = new SystemGraph();
|
||||
gameInterface.reloadGame()->setupScene(scene, systemGraph);
|
||||
renderGraph.updateViewport(viewport);
|
||||
}
|
||||
|
||||
GameView::~GameView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GameView::beginUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
void GameView::update()
|
||||
{
|
||||
static auto startTime = std::chrono::high_resolution_clock::now();
|
||||
systemGraph->run(threadPool, updateTime);
|
||||
scene->update(updateTime);
|
||||
auto endTime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<float> duration = (endTime - startTime);
|
||||
updateTime = duration.count();
|
||||
startTime = endTime;
|
||||
}
|
||||
|
||||
void GameView::commitUpdate()
|
||||
{
|
||||
depthPrepassData.staticDrawList = scene->getStaticMeshes();
|
||||
depthPrepassData.sceneDataBuffer = scene->getSceneDataBuffer();
|
||||
lightCullingData.lightEnv = scene->getLightBuffer();
|
||||
basePassData.staticDrawList = scene->getStaticMeshes();
|
||||
basePassData.sceneDataBuffer = scene->getSceneDataBuffer();
|
||||
#ifdef EDITOR
|
||||
if(showDebug)
|
||||
{
|
||||
debugPassData.vertices = Seele::gDebugVertices;
|
||||
}
|
||||
#endif
|
||||
Seele::gDebugVertices.clear();
|
||||
}
|
||||
|
||||
void GameView::prepareRender()
|
||||
{
|
||||
#ifdef EDITOR
|
||||
renderGraph.updatePassData(depthPrepassData, lightCullingData, basePassData, debugPassData, skyboxData);
|
||||
#else
|
||||
renderGraph.updatePassData(depthPrepassData, lightCullingData, basePassData, skyboxData);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GameView::render()
|
||||
{
|
||||
scene->view<Component::Camera>([&](Component::Camera& cam)
|
||||
{
|
||||
if(cam.mainCamera)
|
||||
{
|
||||
renderGraph.render(cam);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GameView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
||||
{
|
||||
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
|
||||
{
|
||||
//if(code == KeyCode::KEY_R && action == InputAction::PRESS)
|
||||
//{
|
||||
// auto cubeMesh = AssetRegistry::findMesh("cube");
|
||||
// PEntity cube2 = new Entity(scene);
|
||||
// Component::Transform& cube2Transform = cube2->attachComponent<Component::Transform>();
|
||||
// cube2Transform.setPosition(Vector(0, 20, 0));
|
||||
// cube2Transform.setRotation(Quaternion(Vector(0.f, 90.f, 90.f)));
|
||||
// cube2Transform.setScale(Vector(2.f, 2.f, 2.f));
|
||||
// cubeMesh->physicsMesh.type = Component::ColliderType::DYNAMIC;
|
||||
// cube2->attachComponent<Component::Collider>(cubeMesh->physicsMesh);
|
||||
// cube2->attachComponent<Component::StaticMesh>(cubeMesh);
|
||||
// Component::RigidBody& physics2 = cube2->attachComponent<Component::RigidBody>();
|
||||
// physics2.linearMomentum = Vector(0, -10, 0);
|
||||
// physics2.angularMomentum = Vector(0, 0, 0);
|
||||
//}
|
||||
//
|
||||
//if(code == KeyCode::KEY_B && action == InputAction::PRESS)
|
||||
//{
|
||||
// showDebug = !showDebug;
|
||||
// debugPassData.vertices.clear();
|
||||
//}
|
||||
|
||||
input.keys[code] = action != InputAction::RELEASE;
|
||||
});
|
||||
}
|
||||
|
||||
void GameView::mouseMoveCallback(double xPos, double yPos)
|
||||
{
|
||||
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
|
||||
{
|
||||
input.mouseX = static_cast<float>(xPos);
|
||||
input.mouseY = static_cast<float>(yPos);
|
||||
});
|
||||
}
|
||||
|
||||
void GameView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier)
|
||||
{
|
||||
scene->view<Component::KeyboardInput>([=](Component::KeyboardInput& input)
|
||||
{
|
||||
if (button == MouseButton::MOUSE_BUTTON_1)
|
||||
{
|
||||
input.mouse1 = action != InputAction::RELEASE;
|
||||
}
|
||||
if (button == MouseButton::MOUSE_BUTTON_2)
|
||||
{
|
||||
input.mouse2 = action != InputAction::RELEASE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GameView::scrollCallback(double, double)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GameView::fileCallback(int, const char**)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
#include "Window/View.h"
|
||||
#include "Scene/Scene.h"
|
||||
#include "Graphics/RenderPass/DepthPrepass.h"
|
||||
#include "Graphics/RenderPass/LightCullingPass.h"
|
||||
#include "Graphics/RenderPass/BasePass.h"
|
||||
#include "Graphics/RenderPass/DebugPass.h"
|
||||
#include "Graphics/RenderPass/SkyboxRenderPass.h"
|
||||
#include "Platform/Windows/GameInterface.h" // TODO
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
class GameView : public View
|
||||
{
|
||||
public:
|
||||
GameView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
||||
virtual ~GameView();
|
||||
virtual void beginUpdate() override;
|
||||
virtual void update() override;
|
||||
virtual void commitUpdate() override;
|
||||
|
||||
virtual void prepareRender() override;
|
||||
virtual void render() override;
|
||||
private:
|
||||
GameInterface gameInterface;
|
||||
RenderGraph<
|
||||
DepthPrepass,
|
||||
LightCullingPass,
|
||||
BasePass,
|
||||
#ifdef EDITOR
|
||||
DebugPass,
|
||||
#endif
|
||||
SkyboxRenderPass
|
||||
> renderGraph;
|
||||
|
||||
DepthPrepassData depthPrepassData;
|
||||
LightCullingPassData lightCullingData;
|
||||
BasePassData basePassData;
|
||||
SkyboxPassData skyboxData;
|
||||
#ifdef EDITOR
|
||||
DebugPassData debugPassData;
|
||||
#endif
|
||||
|
||||
PScene scene;
|
||||
PSystemGraph systemGraph;
|
||||
dp::thread_pool<> threadPool;
|
||||
float updateTime = 0;
|
||||
#ifdef EDITOR
|
||||
bool showDebug = true;
|
||||
#endif
|
||||
|
||||
virtual void keyCallback(Seele::KeyCode code, Seele::InputAction action, Seele::KeyModifier modifier) override;
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) override;
|
||||
virtual void mouseButtonCallback(Seele::MouseButton button, Seele::InputAction action, Seele::KeyModifier modifier) override;
|
||||
virtual void scrollCallback(double xOffset, double yOffset) override;
|
||||
virtual void fileCallback(int count, const char** paths) override;
|
||||
};
|
||||
DEFINE_REF(GameView)
|
||||
} // namespace Seele
|
||||
@@ -22,19 +22,6 @@ SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreat
|
||||
))
|
||||
, cameraSystem(createInfo.dimensions, Vector(0, 0, 10))
|
||||
{
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ayaka\\Avatar_Girl_Sword_Ayaka_Tex_Body_Diffuse.png");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ayaka\\Avatar_Girl_Sword_Ayaka_Tex_Body_Lightmap.png");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ayaka\\Avatar_Girl_Sword_Ayaka_Tex_Face_Diffuse.png");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ayaka\\Avatar_Girl_Sword_Ayaka_Tex_Hair_Diffuse.png");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ayaka\\Avatar_Girl_Sword_Ayaka_Tex_Hair_Lightmap.png");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ayaka\\Avatar_Girl_Tex_FaceLightmap.png");
|
||||
AssetRegistry::importFile("C:\\Users\\Dynamitos\\TestSeeleProject\\Assets\\Ayaka\\Ayaka.fbx");
|
||||
auto meshAsset = AssetRegistry::findMesh("Ayaka");
|
||||
for(auto mesh : meshAsset->getMeshes())
|
||||
{
|
||||
PActor actor = new Actor(scene);
|
||||
actor->attachComponent<Component::StaticMesh>(mesh->vertexInput, mesh->indexBuffer, mesh->referencedMaterial);
|
||||
}
|
||||
|
||||
//AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Ely\\Ely.fbx");
|
||||
//AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Cube\\cube.obj");
|
||||
@@ -51,14 +38,12 @@ SceneView::~SceneView()
|
||||
|
||||
void SceneView::beginUpdate()
|
||||
{
|
||||
scene->beginUpdate(Gfx::currentFrameDelta);
|
||||
//co_return;
|
||||
}
|
||||
|
||||
void SceneView::update()
|
||||
{
|
||||
cameraSystem.update(viewportCamera, static_cast<float>(Gfx::currentFrameDelta));
|
||||
scene->commitUpdate();
|
||||
//co_return;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ void ViewportControl::update(Component::Camera& camera, float deltaTime)
|
||||
sin(pitch),
|
||||
sin(yaw) * cos(pitch)));
|
||||
camera.viewMatrix = glm::lookAt(position, position + springArm, Vector(0, 1, 0));
|
||||
camera.projectionMatrix = glm::perspective(fieldOfView, aspectRatio, 0.1f, 1000.0f);
|
||||
std::cout << yaw << " " << pitch << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user