Viewport controls
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
target_sources(Engine
|
||||
PUBLIC
|
||||
InspectorView.h
|
||||
InspectorView.cpp
|
||||
SceneView.h
|
||||
SceneView.cpp
|
||||
PRIVATE
|
||||
View.h
|
||||
View.cpp
|
||||
Window.cpp
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#include "InspectorView.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Scene/Actor/Actor.h"
|
||||
#include "Window.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "UI/System.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo)
|
||||
: View(graphics, window, createInfo, "InspectorView")
|
||||
, uiPass(UIPass(graphics, viewport, new Gfx::SwapchainAttachment(window->getGfxHandle())))
|
||||
, textPass(TextPass(graphics, viewport, new Gfx::SwapchainAttachment(window->getGfxHandle())))
|
||||
, uiSystem(new UI::System())
|
||||
{
|
||||
AssetRegistry::importFile("./fonts/Calibri.ttf");
|
||||
PRenderGraphResources resources = new RenderGraphResources();
|
||||
uiPass.setResources(resources);
|
||||
textPass.setResources(resources);
|
||||
uiPass.publishOutputs();
|
||||
textPass.publishOutputs();
|
||||
uiPass.createRenderPass();
|
||||
textPass.createRenderPass();
|
||||
}
|
||||
|
||||
InspectorView::~InspectorView()
|
||||
{
|
||||
}
|
||||
|
||||
void InspectorView::beginUpdate()
|
||||
{
|
||||
//co_return;
|
||||
}
|
||||
|
||||
void InspectorView::update()
|
||||
{
|
||||
//co_return;
|
||||
}
|
||||
|
||||
void InspectorView::commitUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
void InspectorView::prepareRender()
|
||||
{
|
||||
uiPass.updateViewFrame(uiSystem->getUIPassData());
|
||||
textPass.updateViewFrame(uiSystem->getTextPassData());
|
||||
}
|
||||
|
||||
void InspectorView::render()
|
||||
{
|
||||
uiPass.beginFrame();
|
||||
textPass.beginFrame();
|
||||
uiPass.render();
|
||||
textPass.render();
|
||||
uiPass.endFrame();
|
||||
textPass.endFrame();
|
||||
}
|
||||
|
||||
void InspectorView::keyCallback(KeyCode, InputAction, KeyModifier)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InspectorView::mouseMoveCallback(double, double)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InspectorView::mouseButtonCallback(MouseButton, InputAction, KeyModifier)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InspectorView::scrollCallback(double, double)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InspectorView::fileCallback(int, const char**)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
#include "View.h"
|
||||
#include "Graphics/RenderPass/RenderGraph.h"
|
||||
#include "Graphics/RenderPass/UIPass.h"
|
||||
#include "Graphics/RenderPass/TextPass.h"
|
||||
#include "UI/Elements/Panel.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_REF(Actor)
|
||||
class InspectorView : public View
|
||||
{
|
||||
public:
|
||||
InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo);
|
||||
virtual ~InspectorView();
|
||||
|
||||
virtual void beginUpdate() override;
|
||||
virtual void update() override;
|
||||
virtual void commitUpdate() override;
|
||||
|
||||
virtual void prepareRender() override;
|
||||
virtual void render() override;
|
||||
void selectActor();
|
||||
protected:
|
||||
UIPass uiPass;
|
||||
TextPass textPass;
|
||||
|
||||
UIPassData uiPassData;
|
||||
TextPassData textPassData;
|
||||
|
||||
UI::PSystem uiSystem;
|
||||
PActor selectedActor;
|
||||
|
||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) override;
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) override;
|
||||
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) override;
|
||||
virtual void scrollCallback(double xOffset, double yOffset) override;
|
||||
virtual void fileCallback(int count, const char** paths) override;
|
||||
};
|
||||
DEFINE_REF(InspectorView)
|
||||
} // namespace Seele
|
||||
@@ -1,170 +0,0 @@
|
||||
#include "SceneView.h"
|
||||
#include "Scene/Scene.h"
|
||||
#include "Window.h"
|
||||
#include "Graphics/Mesh.h"
|
||||
#include "Graphics/Graphics.h"
|
||||
#include "Asset/MeshAsset.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Scene/Actor/CameraActor.h"
|
||||
#include "Scene/Component/Camera.h"
|
||||
#include "Scene/Component/StaticMesh.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo)
|
||||
: View(graphics, owner, createInfo, "SceneView")
|
||||
, scene(new Scene(graphics))
|
||||
, activeCamera(new CameraActor(scene))
|
||||
, depthPrepass(DepthPrepass(graphics, viewport, activeCamera))
|
||||
, lightCullingPass(LightCullingPass(graphics, viewport, activeCamera))
|
||||
, basePass(BasePass(graphics, viewport, activeCamera))
|
||||
, cameraSystem(scene->registry)
|
||||
{
|
||||
activeCamera->getCameraComponent().setViewport(viewport);
|
||||
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");
|
||||
AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Plane\\plane.fbx");
|
||||
|
||||
cameraSystem.run(pool);
|
||||
|
||||
PRenderGraphResources resources = new RenderGraphResources();
|
||||
depthPrepass.setResources(resources);
|
||||
lightCullingPass.setResources(resources);
|
||||
basePass.setResources(resources);
|
||||
|
||||
depthPrepass.publishOutputs();
|
||||
lightCullingPass.publishOutputs();
|
||||
basePass.publishOutputs();
|
||||
|
||||
depthPrepass.createRenderPass();
|
||||
lightCullingPass.createRenderPass();
|
||||
basePass.createRenderPass();
|
||||
}
|
||||
|
||||
Seele::SceneView::~SceneView()
|
||||
{
|
||||
}
|
||||
|
||||
void SceneView::beginUpdate()
|
||||
{
|
||||
scene->beginUpdate(Gfx::currentFrameDelta);
|
||||
//co_return;
|
||||
}
|
||||
|
||||
void SceneView::update()
|
||||
{
|
||||
scene->commitUpdate();
|
||||
//co_return;
|
||||
}
|
||||
|
||||
void SceneView::commitUpdate()
|
||||
{
|
||||
depthPrepassData.staticDrawList = scene->getStaticMeshes();
|
||||
lightCullingPassData.lightEnv = scene->getLightBuffer();
|
||||
basePassData.staticDrawList = scene->getStaticMeshes();
|
||||
}
|
||||
|
||||
void SceneView::prepareRender()
|
||||
{
|
||||
depthPrepass.updateViewFrame(depthPrepassData);
|
||||
lightCullingPass.updateViewFrame(lightCullingPassData);
|
||||
basePass.updateViewFrame(basePassData);
|
||||
}
|
||||
|
||||
void SceneView::render()
|
||||
{
|
||||
cameraSystem.run(pool);
|
||||
depthPrepass.beginFrame();
|
||||
lightCullingPass.beginFrame();
|
||||
basePass.beginFrame();
|
||||
depthPrepass.render();
|
||||
lightCullingPass.render();
|
||||
basePass.render();
|
||||
depthPrepass.endFrame();
|
||||
lightCullingPass.endFrame();
|
||||
basePass.endFrame();
|
||||
}
|
||||
|
||||
static float cameraSpeed = 1;
|
||||
|
||||
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier mod)
|
||||
{
|
||||
if((KeyModifierFlags)mod & (KeyModifierFlags)KeyModifier::MOD_SHIFT)
|
||||
{
|
||||
cameraSpeed = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
cameraSpeed = 1;
|
||||
}
|
||||
if(action != InputAction::RELEASE)
|
||||
{
|
||||
if(code == KeyCode::KEY_W)
|
||||
{
|
||||
activeCamera->getCameraComponent().moveX(1);
|
||||
}
|
||||
if(code == KeyCode::KEY_S)
|
||||
{
|
||||
activeCamera->getCameraComponent().moveX(-1);
|
||||
}
|
||||
if(code == KeyCode::KEY_A)
|
||||
{
|
||||
activeCamera->getCameraComponent().moveY(1);
|
||||
}
|
||||
if(code == KeyCode::KEY_D)
|
||||
{
|
||||
activeCamera->getCameraComponent().moveY(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool mouseDown = false;
|
||||
|
||||
void SceneView::mouseMoveCallback(double xPos, double yPos)
|
||||
{
|
||||
static double prevXPos = 0.0f, prevYPos = 0.0f;
|
||||
double deltaX = prevXPos - xPos;
|
||||
double deltaY = prevYPos - yPos;
|
||||
prevXPos = xPos;
|
||||
prevYPos = yPos;
|
||||
if(mouseDown)
|
||||
{
|
||||
activeCamera->getCameraComponent().mouseMove((float)deltaX, (float)deltaY);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier)
|
||||
{
|
||||
if(button == MouseButton::MOUSE_BUTTON_2 && action != InputAction::RELEASE)
|
||||
{
|
||||
mouseDown = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SceneView::scrollCallback(double, double yOffset)
|
||||
{
|
||||
activeCamera->getCameraComponent().mouseScroll(static_cast<float>(yOffset));
|
||||
}
|
||||
|
||||
void SceneView::fileCallback(int, const char**)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#pragma once
|
||||
#include <thread_pool/thread_pool.h>
|
||||
#include "View.h"
|
||||
#include "Graphics/RenderPass/DepthPrepass.h"
|
||||
#include "Graphics/RenderPass/LightCullingPass.h"
|
||||
#include "Graphics/RenderPass/BasePass.h"
|
||||
#include "Scene/System/CameraSystem.h"
|
||||
namespace Seele
|
||||
{
|
||||
DECLARE_REF(Scene)
|
||||
DECLARE_REF(CameraActor)
|
||||
|
||||
class SceneView : public View
|
||||
{
|
||||
public:
|
||||
SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo);
|
||||
~SceneView();
|
||||
virtual void beginUpdate() override;
|
||||
virtual void update() override;
|
||||
virtual void commitUpdate() override;
|
||||
|
||||
virtual void prepareRender() override;
|
||||
virtual void render() override;
|
||||
|
||||
PScene getScene() const { return scene; }
|
||||
private:
|
||||
PScene scene;
|
||||
PCameraActor activeCamera;
|
||||
|
||||
DepthPrepass depthPrepass;
|
||||
LightCullingPass lightCullingPass;
|
||||
BasePass basePass;
|
||||
|
||||
DepthPrepassData depthPrepassData;
|
||||
LightCullingPassData lightCullingPassData;
|
||||
BasePassData basePassData;
|
||||
|
||||
dp::thread_pool<> pool;
|
||||
System::CameraSystem cameraSystem;
|
||||
|
||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) override;
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) override;
|
||||
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) override;
|
||||
virtual void scrollCallback(double xOffset, double yOffset) override;
|
||||
virtual void fileCallback(int count, const char** paths) override;
|
||||
};
|
||||
DEFINE_REF(SceneView)
|
||||
} // namespace Seele
|
||||
Reference in New Issue
Block a user