Adding skeleton
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
FlyCam.h
|
||||
FlyCam.cpp)
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "FlyCam.h"
|
||||
|
||||
FlyCam::FlyCam(PScene scene)
|
||||
: Actor(scene)
|
||||
{
|
||||
attachComponent<Component::Camera>().mainCamera = true;
|
||||
attachComponent<Component::KeyboardInput>();
|
||||
}
|
||||
|
||||
FlyCam::~FlyCam()
|
||||
{}
|
||||
|
||||
Component::Camera& FlyCam::getCamera()
|
||||
{
|
||||
return accessComponent<Component::Camera>();
|
||||
}
|
||||
|
||||
Component::KeyboardInput& FlyCam::getKeyboardInput()
|
||||
{
|
||||
return accessComponent<Component::KeyboardInput>();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include "Seele/MinimalEngine.h"
|
||||
#include <Seele/Actor/Actor.h>
|
||||
#include <Seele/Component/KeyboardInput.h>
|
||||
#include <Seele/Component/Camera.h>
|
||||
|
||||
class FlyCam : public Actor
|
||||
{
|
||||
public:
|
||||
FlyCam(PScene scene);
|
||||
virtual ~FlyCam();
|
||||
Component::KeyboardInput& getKeyboardInput();
|
||||
Component::Camera& getCamera();
|
||||
private:
|
||||
};
|
||||
DEFINE_REF(FlyCam)
|
||||
@@ -0,0 +1,8 @@
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
Define.h
|
||||
MeshShadingDemoGame.h
|
||||
MeshShadingDemoGame.cpp)
|
||||
|
||||
add_subdirectory(Actor/)
|
||||
add_subdirectory(System/)
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "Seele/MinimalEngine.h"
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef BUILD_DLL
|
||||
#define MESHSHADINGDEMO_API __declspec(dllexport)
|
||||
#else
|
||||
#define MESHSHADINGDEMO_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define MESHSHADINGDEMO_API
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "MeshShadingDemoGame.h"
|
||||
#include "Actor/FlyCam.h"
|
||||
#include "Seele/Asset/AssetRegistry.h"
|
||||
#include "Seele/Component/Transform.h"
|
||||
#include "System/FlyCamSystem.h"
|
||||
|
||||
MeshShadingDemoGame::MeshShadingDemoGame()
|
||||
{
|
||||
}
|
||||
|
||||
MeshShadingDemoGame::~MeshShadingDemoGame()
|
||||
{
|
||||
}
|
||||
|
||||
void MeshShadingDemoGame::setupScene(PScene scene, PSystemGraph graph)
|
||||
{
|
||||
cube = new StaticMeshActor(scene, AssetRegistry::findMesh("cube"));
|
||||
// cube->accessComponent<Component::Transform>().setScale(Vector(50, 50, 50));
|
||||
camera = new FlyCam(scene);
|
||||
light = new DirectionalLightActor(scene, Vector4(1, 1, 1, 1), Vector(0, -1, 0));
|
||||
graph->addSystem(new FlyCamSystem(scene));
|
||||
}
|
||||
|
||||
Game* createInstance()
|
||||
{
|
||||
return new MeshShadingDemoGame();
|
||||
}
|
||||
|
||||
void destroyInstance(Game *game)
|
||||
{
|
||||
delete game;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "Actor/FlyCam.h"
|
||||
#include "Define.h"
|
||||
#include <Seele/Actor/StaticMeshActor.h>
|
||||
#include <Seele/Actor/DirectionalLightActor.h>
|
||||
#include <Seele/Game.h>
|
||||
|
||||
class MESHSHADINGDEMO_API MeshShadingDemoGame : public Game {
|
||||
public:
|
||||
MeshShadingDemoGame();
|
||||
virtual ~MeshShadingDemoGame();
|
||||
virtual void setupScene(PScene scene, PSystemGraph graph) override;
|
||||
|
||||
private:
|
||||
OStaticMeshActor cube;
|
||||
OFlyCam camera;
|
||||
ODirectionalLightActor light;
|
||||
};
|
||||
|
||||
extern "C" MESHSHADINGDEMO_API Game *createInstance();
|
||||
extern "C" MESHSHADINGDEMO_API void destroyInstance(Game *game);
|
||||
@@ -0,0 +1,4 @@
|
||||
target_sources(MeshShadingDemo
|
||||
PUBLIC
|
||||
FlyCamSystem.h
|
||||
FlyCamSystem.cpp)
|
||||
@@ -0,0 +1,48 @@
|
||||
#include "FlyCamSystem.h"
|
||||
#include "Seele/System/ComponentSystem.h"
|
||||
|
||||
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);
|
||||
if(input.keys[KeyCode::KEY_LEFT_SHIFT])
|
||||
{
|
||||
cameraMove *= 100;
|
||||
}
|
||||
Vector forward = transform.getForward();
|
||||
Vector side = transform.getRight();
|
||||
Vector moveVector = Vector();
|
||||
|
||||
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)
|
||||
{
|
||||
camera.mouseMove(input.deltaX, input.deltaY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "Define.h"
|
||||
#include "Seele/MinimalEngine.h"
|
||||
#include <Seele/Scene/Scene.h>
|
||||
#include <Seele/System/ComponentSystem.h>
|
||||
#include <Seele/Component/Camera.h>
|
||||
#include <Seele/Component/KeyboardInput.h>
|
||||
|
||||
class FlyCamSystem : public System::ComponentSystem<
|
||||
Component::KeyboardInput,
|
||||
Component::Camera,
|
||||
Component::Transform>
|
||||
{
|
||||
public:
|
||||
FlyCamSystem(PScene scene);
|
||||
virtual ~FlyCamSystem();
|
||||
virtual void update(Seele::Component::KeyboardInput& input, Seele::Component::Camera& camera, Seele::Component::Transform& transform) override;
|
||||
private:
|
||||
float lastMouseX;
|
||||
float lastMouseY;
|
||||
};
|
||||
DEFINE_REF(FlyCamSystem)
|
||||
@@ -1,34 +0,0 @@
|
||||
#include <Window/WindowManager.h>
|
||||
#include <Asset/AssetRegistry.h>
|
||||
#include <Window/GameView.h>
|
||||
#include <Graphics/Vulkan/VulkanGraphics.h>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
int main()
|
||||
{
|
||||
Gfx::PGraphics graphics = new Vulkan::Graphics();
|
||||
GraphicsInitializer initializer;
|
||||
graphics->init(initializer);
|
||||
|
||||
PWindowManager windowManager = new WindowManager();
|
||||
AssetRegistry::init("Assets", graphics);
|
||||
|
||||
WindowCreateInfo mainWindowInfo;
|
||||
mainWindowInfo.title = "MeshShadingDemo";
|
||||
mainWindowInfo.width = 1280;
|
||||
mainWindowInfo.height = 720;
|
||||
mainWindowInfo.bFullscreen = false;
|
||||
mainWindowInfo.numSamples = 1;
|
||||
mainWindowInfo.pixelFormat = Gfx::SE_FORMAT_B8G8R8A8_UNORM;
|
||||
auto window = windowManager->addWindow(graphics, mainWindowInfo);
|
||||
ViewportCreateInfo sceneViewInfo;
|
||||
sceneViewInfo.dimensions.size.x = 1280;
|
||||
sceneViewInfo.dimensions.size.y = 720;
|
||||
sceneViewInfo.dimensions.offset.x = 0;
|
||||
sceneViewInfo.dimensions.offset.y = 0;
|
||||
PGameView sceneView = new GameView(graphics, window, sceneViewInfo, "");
|
||||
sceneView->setFocused();
|
||||
window->render();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user