From 3895fbb3d3fb30cbd74d8f21aed2ff00de2d136c Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Mon, 22 Apr 2024 12:47:05 +0200 Subject: [PATCH] Adding skeleton --- .clang-format | 244 +++++++++++++++++++++++++++++++ .clangd | 0 .gitmodules | 3 + CMakeLists.txt | 12 +- import/models/cube.fbx | Bin 0 -> 15244 bytes import/models/cubeMaterial0.json | 22 +++ src/Actor/CMakeLists.txt | 4 + src/Actor/FlyCam.cpp | 21 +++ src/Actor/FlyCam.h | 17 +++ src/CMakeLists.txt | 8 + src/Define.h | 14 ++ src/MeshShadingDemoGame.cpp | 32 ++++ src/MeshShadingDemoGame.h | 21 +++ src/System/CMakeLists.txt | 4 + src/System/FlyCamSystem.cpp | 48 ++++++ src/System/FlyCamSystem.h | 22 +++ src/main.cpp | 34 ----- vcpkg | 1 + vcpkg.json | 19 +++ 19 files changed, 491 insertions(+), 35 deletions(-) create mode 100644 .clang-format create mode 100644 .clangd create mode 100644 .gitmodules create mode 100644 import/models/cube.fbx create mode 100644 import/models/cubeMaterial0.json create mode 100644 src/Actor/CMakeLists.txt create mode 100644 src/Actor/FlyCam.cpp create mode 100644 src/Actor/FlyCam.h create mode 100644 src/CMakeLists.txt create mode 100644 src/Define.h create mode 100644 src/MeshShadingDemoGame.cpp create mode 100644 src/MeshShadingDemoGame.h create mode 100644 src/System/CMakeLists.txt create mode 100644 src/System/FlyCamSystem.cpp create mode 100644 src/System/FlyCamSystem.h delete mode 100644 src/main.cpp create mode 160000 vcpkg create mode 100644 vcpkg.json diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..dcf16f8 --- /dev/null +++ b/.clang-format @@ -0,0 +1,244 @@ +# BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLinesAtEOF: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... + diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..e69de29 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e41f858 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vcpkg"] + path = vcpkg + url = https://github.com/Microsoft/vcpkg.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 5384cca..d6f896c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ if(${CMAKE_VERSION} VERSION_LESS 3.12) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) endif() set(CMAKE_CXX_STANDARD 20) +set(VCPKG_INSTALL_OPTIONS "--allow-unsupported") + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake) project(MeshShadingDemo) @@ -24,7 +27,14 @@ find_package(Ktx CONFIG REQUIRED) find_package(nlohmann_json CONFIG REQUIRED) find_package(fmt CONFIG REQUIRED) find_package(VulkanMemoryAllocator CONFIG REQUIRED) +find_package(glslang CONFIG REQUIRED) find_package(Seele REQUIRED) -add_library(MeshShadingDemo main.cpp) +add_library(MeshShadingDemo SHARED "") target_link_libraries(MeshShadingDemo PUBLIC Seele::Engine) + +target_include_directories(MeshShadingDemo PRIVATE src/) + +target_compile_definitions(MeshShadingDemo PRIVATE BUILD_DLL) + +add_subdirectory(src/) diff --git a/import/models/cube.fbx b/import/models/cube.fbx new file mode 100644 index 0000000000000000000000000000000000000000..0c8add83891b1302f99fbf4b3e08fd1649d62daa GIT binary patch literal 15244 zcmc&*dypK(d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KLZ!vKf*h0&1Z(Tvv{Yah|PAa=Q9gwK34T?%ko>iXB97>!h8MJ#F&+_nQ5>@ zXNMH4)HC#yr@;w ziJu~{`8oBK8Pz8+7o?E^@rS>d8tBtvf01t9FHHs5*I6wC@gQwmmb=I67aZQacX<2lmp!p5`t*?>oLTkArfq8)?>^mm zsPXAPxck|f#OaGppML+yU55q_-7;^uJ(|3HL$=xT-fH_*Q%%iffBbTNv-yt~fB%a! zZo9&G@Cz$X+^*D_Lch&Yg5@KjKTz&=;R$`u~c{eMv^EB@_ z6d4nM8AH1h*uxaPcjG=$^V$24%rRPL)jqlBGh=m2<{oTooqw?Q!#}_AhtE8EukSv8 zX=>$dFTeci<15$x`tXPU{lNqMzy0g&A07VX8vB9YKYPkNd*`C>cU;l3Na=`1Yk*#g zEJl~3ML2i^O9YyxRyY6xt2W`8I-^x+S%xD%6CwMW01=f2KBY(CgS=o*bhIMqSLbx>7(d;Q54ej=;?d83&UY=J7 zIQ>%M%$w3nV9M94?F;lFC4sM}@UA^#|=Q&llIG^lNs&YDs6mFY!8XBL0!gujMitWnSS6_MyP`0pd^)>GF@ zaWw`ujGjt&EMp6?CJVkAHNjJibuVbFxO$#4>131cunTXsmY*)Wg zgFg&{8xc{0SH65v&_ zf_i031I$Q)R!RCM(pO$nVm;8_wq22O!HP52 z{!dCa3&wq}S%50;Cp6CL8HX}|k1xSEMzry`jVFRb0bRk%*{6;+z4GEejDBz5Z~k!6 i|13M8SMqOB|G&yd!}s0(+UZ{&c=zpDZ)6`>(ei%>LqK!@ literal 0 HcmV?d00001 diff --git a/import/models/cubeMaterial0.json b/import/models/cubeMaterial0.json new file mode 100644 index 0000000..b886006 --- /dev/null +++ b/import/models/cubeMaterial0.json @@ -0,0 +1,22 @@ +{ + "code": [ + { + "exp": "Const", + "value": "input.vertexColor.xyz" + }, + { + "exp": "Const", + "value": "float3(0, 0, 1)" + }, + { + "exp": "BRDF", + "profile": "CelShading", + "values": { + "baseColor": 0, + "normal": 1 + } + } + ], + "name": "cubeMaterial0", + "profile": "CelShading" +} \ No newline at end of file diff --git a/src/Actor/CMakeLists.txt b/src/Actor/CMakeLists.txt new file mode 100644 index 0000000..53ff0be --- /dev/null +++ b/src/Actor/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(MeshShadingDemo + PUBLIC + FlyCam.h + FlyCam.cpp) \ No newline at end of file diff --git a/src/Actor/FlyCam.cpp b/src/Actor/FlyCam.cpp new file mode 100644 index 0000000..a1391d3 --- /dev/null +++ b/src/Actor/FlyCam.cpp @@ -0,0 +1,21 @@ +#include "FlyCam.h" + +FlyCam::FlyCam(PScene scene) + : Actor(scene) +{ + attachComponent().mainCamera = true; + attachComponent(); +} + +FlyCam::~FlyCam() +{} + +Component::Camera& FlyCam::getCamera() +{ + return accessComponent(); +} + +Component::KeyboardInput& FlyCam::getKeyboardInput() +{ + return accessComponent(); +} \ No newline at end of file diff --git a/src/Actor/FlyCam.h b/src/Actor/FlyCam.h new file mode 100644 index 0000000..1975890 --- /dev/null +++ b/src/Actor/FlyCam.h @@ -0,0 +1,17 @@ +#pragma once +#include "Define.h" +#include "Seele/MinimalEngine.h" +#include +#include +#include + +class FlyCam : public Actor +{ +public: + FlyCam(PScene scene); + virtual ~FlyCam(); + Component::KeyboardInput& getKeyboardInput(); + Component::Camera& getCamera(); +private: +}; +DEFINE_REF(FlyCam) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..b9a2e61 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,8 @@ +target_sources(MeshShadingDemo + PUBLIC + Define.h + MeshShadingDemoGame.h + MeshShadingDemoGame.cpp) + +add_subdirectory(Actor/) +add_subdirectory(System/) diff --git a/src/Define.h b/src/Define.h new file mode 100644 index 0000000..77727e0 --- /dev/null +++ b/src/Define.h @@ -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 \ No newline at end of file diff --git a/src/MeshShadingDemoGame.cpp b/src/MeshShadingDemoGame.cpp new file mode 100644 index 0000000..c13a679 --- /dev/null +++ b/src/MeshShadingDemoGame.cpp @@ -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().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; +} \ No newline at end of file diff --git a/src/MeshShadingDemoGame.h b/src/MeshShadingDemoGame.h new file mode 100644 index 0000000..8825491 --- /dev/null +++ b/src/MeshShadingDemoGame.h @@ -0,0 +1,21 @@ +#pragma once +#include "Actor/FlyCam.h" +#include "Define.h" +#include +#include +#include + +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); \ No newline at end of file diff --git a/src/System/CMakeLists.txt b/src/System/CMakeLists.txt new file mode 100644 index 0000000..dd9248d --- /dev/null +++ b/src/System/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(MeshShadingDemo + PUBLIC + FlyCamSystem.h + FlyCamSystem.cpp) \ No newline at end of file diff --git a/src/System/FlyCamSystem.cpp b/src/System/FlyCamSystem.cpp new file mode 100644 index 0000000..657e726 --- /dev/null +++ b/src/System/FlyCamSystem.cpp @@ -0,0 +1,48 @@ +#include "FlyCamSystem.h" +#include "Seele/System/ComponentSystem.h" + +FlyCamSystem::FlyCamSystem(PScene scene) + : System::ComponentSystem(scene) {} + +FlyCamSystem::~FlyCamSystem() {} + +void FlyCamSystem::update(Component::KeyboardInput& input, Component::Camera& camera, Component::Transform& transform) { + float cameraMove = static_cast(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); + } +} \ No newline at end of file diff --git a/src/System/FlyCamSystem.h b/src/System/FlyCamSystem.h new file mode 100644 index 0000000..e38d7f4 --- /dev/null +++ b/src/System/FlyCamSystem.h @@ -0,0 +1,22 @@ +#pragma once +#include "Define.h" +#include "Seele/MinimalEngine.h" +#include +#include +#include +#include + +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) \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index e1c3eb9..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include - -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; -} diff --git a/vcpkg b/vcpkg new file mode 160000 index 0000000..501cb01 --- /dev/null +++ b/vcpkg @@ -0,0 +1 @@ +Subproject commit 501cb01e517ee5689577bb01ba8bd1b4c1041a53 diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..e07c93c --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,19 @@ +{ + "dependencies": [ + "assimp", + "entt", + "stb", + "entt", + "freetype", + "glfw3", + "glm", + "ktx", + "nlohmann-json", + "fmt", + "gtest", + "vulkan-memory-allocator", + "shader-slang", + "spirv-cross", + "glslang" + ] +} \ No newline at end of file