2020-03-05 11:43:38 +01:00
|
|
|
#include "SceneView.h"
|
2020-06-08 01:44:47 +02:00
|
|
|
#include "Scene/Scene.h"
|
2020-05-05 01:51:13 +02:00
|
|
|
#include "Window.h"
|
2021-10-15 23:12:29 +02:00
|
|
|
#include "Asset/AssetRegistry.h"
|
2020-10-03 11:00:10 +02:00
|
|
|
#include "Scene/Actor/CameraActor.h"
|
2020-10-29 02:22:01 +01:00
|
|
|
#include "Scene/Components/CameraComponent.h"
|
2020-03-05 11:43:38 +01:00
|
|
|
|
2020-08-06 00:54:43 +02:00
|
|
|
using namespace Seele;
|
|
|
|
|
|
2020-05-05 01:51:13 +02:00
|
|
|
Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo)
|
2021-11-01 20:25:16 +01:00
|
|
|
: View(graphics, owner, createInfo)
|
|
|
|
|
, activeCamera(new CameraActor())
|
|
|
|
|
, depthPrepass(DepthPrepass(graphics, viewport, activeCamera))
|
|
|
|
|
, lightCullingPass(LightCullingPass(graphics, viewport, activeCamera))
|
|
|
|
|
, basePass(BasePass(graphics, viewport, activeCamera))
|
2020-03-05 11:43:38 +01:00
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
scene = new Scene(graphics);
|
|
|
|
|
scene->addActor(activeCamera);
|
|
|
|
|
AssetRegistry::importFile("/home/dynamitos/Assets/Ayaka/Avatar_Girl_Sword_Ayaka_Tex_Body_Diffuse.png");
|
|
|
|
|
AssetRegistry::importFile("/home/dynamitos/Assets/Ayaka/Avatar_Girl_Sword_Ayaka_Tex_Body_Lightmap.png");
|
|
|
|
|
AssetRegistry::importFile("/home/dynamitos/Assets/Ayaka/Avatar_Girl_Sword_Ayaka_Tex_Face_Diffuse.png");
|
|
|
|
|
AssetRegistry::importFile("/home/dynamitos/Assets/Ayaka/Avatar_Girl_Sword_Ayaka_Tex_Hair_Diffuse.png");
|
|
|
|
|
AssetRegistry::importFile("/home/dynamitos/Assets/Ayaka/Avatar_Girl_Sword_Ayaka_Tex_Hair_Lightmap.png");
|
|
|
|
|
AssetRegistry::importFile("/home/dynamitos/Assets/Ayaka/Avatar_Girl_Tex_FaceLightmap.png");
|
|
|
|
|
AssetRegistry::importFile("/home/dynamitos/Assets/Ayaka/Ayaka.fbx");
|
|
|
|
|
PPrimitiveComponent ayaka = new PrimitiveComponent(AssetRegistry::findMesh("Ayaka"));
|
|
|
|
|
ayaka->addWorldTranslation(Vector(0, 0, 0));
|
|
|
|
|
ayaka->setWorldScale(Vector(10, 10, 10));
|
|
|
|
|
scene->addPrimitiveComponent(ayaka);
|
2021-10-19 11:00:39 +02:00
|
|
|
|
2021-11-01 20:25:16 +01:00
|
|
|
/*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");
|
|
|
|
|
PPrimitiveComponent plane = new PrimitiveComponent(AssetRegistry::findMesh("plane"));
|
|
|
|
|
plane->setWorldScale(Vector(100, 100, 100));
|
|
|
|
|
PPrimitiveComponent arissa = new PrimitiveComponent(AssetRegistry::findMesh("Ely"));
|
|
|
|
|
arissa->addWorldTranslation(Vector(0, 0, 100));
|
|
|
|
|
arissa->setWorldScale(Vector(0.1f, 0.1f, 0.1f));
|
|
|
|
|
scene->addPrimitiveComponent(plane);
|
|
|
|
|
scene->addPrimitiveComponent(arissa);*/
|
2021-10-15 23:12:29 +02:00
|
|
|
|
2021-11-01 20:25:16 +01:00
|
|
|
PRenderGraphResources resources = new RenderGraphResources();
|
|
|
|
|
depthPrepass.setResources(resources);
|
|
|
|
|
lightCullingPass.setResources(resources);
|
|
|
|
|
basePass.setResources(resources);
|
2021-10-15 23:12:29 +02:00
|
|
|
|
2021-11-01 20:25:16 +01:00
|
|
|
depthPrepass.publishOutputs();
|
|
|
|
|
lightCullingPass.publishOutputs();
|
|
|
|
|
basePass.publishOutputs();
|
2021-10-15 23:12:29 +02:00
|
|
|
|
2021-11-01 20:25:16 +01:00
|
|
|
depthPrepass.createRenderPass();
|
|
|
|
|
lightCullingPass.createRenderPass();
|
|
|
|
|
basePass.createRenderPass();
|
2020-03-05 11:43:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Seele::SceneView::~SceneView()
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-10-29 02:22:01 +01:00
|
|
|
|
2021-10-15 23:12:29 +02:00
|
|
|
void SceneView::beginUpdate()
|
2021-01-19 15:30:00 +01:00
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
View::beginUpdate();
|
|
|
|
|
scene->tick(Gfx::currentFrameDelta);
|
2021-01-19 15:30:00 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-01 19:55:04 +02:00
|
|
|
void SceneView::update()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-15 23:12:29 +02:00
|
|
|
void SceneView::commitUpdate()
|
2021-10-01 19:55:04 +02:00
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
depthPrepassData.staticDrawList = scene->getStaticMeshes();
|
|
|
|
|
lightCullingPassData.lightEnv = scene->getLightBuffer();
|
|
|
|
|
basePassData.staticDrawList = scene->getStaticMeshes();
|
2021-10-01 19:55:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SceneView::prepareRender()
|
|
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
depthPrepass.updateViewFrame(depthPrepassData);
|
|
|
|
|
lightCullingPass.updateViewFrame(lightCullingPassData);
|
|
|
|
|
basePass.updateViewFrame(basePassData);
|
2021-10-01 19:55:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SceneView::render()
|
|
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
depthPrepass.beginFrame();
|
|
|
|
|
lightCullingPass.beginFrame();
|
|
|
|
|
basePass.beginFrame();
|
2021-10-15 23:12:29 +02:00
|
|
|
|
2021-11-01 20:25:16 +01:00
|
|
|
depthPrepass.render();
|
|
|
|
|
lightCullingPass.render();
|
|
|
|
|
basePass.render();
|
2021-10-15 23:12:29 +02:00
|
|
|
|
2021-11-01 20:25:16 +01:00
|
|
|
depthPrepass.endFrame();
|
|
|
|
|
lightCullingPass.endFrame();
|
|
|
|
|
basePass.endFrame();
|
2021-10-01 19:55:04 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-01 16:40:14 +02:00
|
|
|
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier)
|
2020-11-03 01:18:30 +01:00
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
if(action != InputAction::RELEASE)
|
|
|
|
|
{
|
|
|
|
|
if(code == KeyCode::KEY_W)
|
|
|
|
|
{
|
|
|
|
|
activeCamera->getCameraComponent()->moveOrigin(1);
|
|
|
|
|
}
|
|
|
|
|
if(code == KeyCode::KEY_S)
|
|
|
|
|
{
|
|
|
|
|
activeCamera->getCameraComponent()->moveOrigin(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-03 01:18:30 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 15:30:00 +01:00
|
|
|
static bool mouseDown = false;
|
|
|
|
|
|
2020-11-03 01:18:30 +01:00
|
|
|
void SceneView::mouseMoveCallback(double xPos, double yPos)
|
|
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
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);
|
|
|
|
|
}
|
2020-11-03 01:18:30 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-01 16:40:14 +02:00
|
|
|
void SceneView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier)
|
2020-10-29 02:22:01 +01:00
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
if(button == MouseButton::MOUSE_BUTTON_1 && action != InputAction::RELEASE)
|
|
|
|
|
{
|
|
|
|
|
mouseDown = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mouseDown = false;
|
|
|
|
|
}
|
2021-01-19 15:30:00 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-01 16:40:14 +02:00
|
|
|
void SceneView::scrollCallback(double, double yOffset)
|
2021-01-19 15:30:00 +01:00
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
activeCamera->getCameraComponent()->mouseScroll(yOffset);
|
2021-01-19 15:30:00 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-01 16:40:14 +02:00
|
|
|
void SceneView::fileCallback(int, const char**)
|
2021-01-19 15:30:00 +01:00
|
|
|
{
|
2021-11-01 20:25:16 +01:00
|
|
|
|
2020-10-29 02:22:01 +01:00
|
|
|
}
|