diff --git a/.vscode/settings.json b/.vscode/settings.json index 745b8e1..8b81d0a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,6 @@ { "telemetry.enableTelemetry": false, "cmake.buildDirectory": "${workspaceFolder}/bin/${buildType}", - "git.enabled": false, "files.associations": { "*.h": "cpp", "*.ush": "hlsl", diff --git a/res/shaders/FluidForward.slang b/res/shaders/FluidForward.slang deleted file mode 100644 index c7d083f..0000000 --- a/res/shaders/FluidForward.slang +++ /dev/null @@ -1,39 +0,0 @@ -import LightEnv; - -struct VertexInput -{ - float3 basePosition; - float3 position; - float3 velocity; -} - -struct ViewParameter -{ - float4 cameraPos_WS; - float4x4 viewMatrix; - float4x4 projectionMatrix; - PointLight light; -} -layout(set = 0, std430) -ParameterBlock gViewParams; - -struct VertexToPixel -{ - float4 position_CS : SV_Position; -} - -VertexToPixel vertexMain(VertexInput input) -{ - VertexToPixel output = (VertexToPixel)0; - float3 cameraRight_WS = float3(gViewParams.viewMatrix[0][0], gViewParams.viewMatrix[0][1], gViewParams.viewMatrix[0][2]); - float3 cameraUp_WS = float3(gViewParams.viewMatrix[1][0], gViewParams.viewMatrix[1][1], gViewParams.viewMatrix[1][2]); - float3 worldPosition = input.position + cameraRight_WS * input.basePosition.x + cameraUp_WS * input.basePosition.y; - float4 viewPosition = mul(gViewParams.viewMatrix, float4(worldPosition, 1)); - output.position_CS = mul(gViewParams.projectionMatrix, viewPosition); - return output; -} - -float4 fragMain(VertexToPixel input) : SV_Target -{ - return float4(0, 1, 0, 0.001f); -} \ No newline at end of file diff --git a/res/shaders/ForwardPlus.slang b/res/shaders/ForwardPlus.slang index c5c4dc5..cccda9e 100644 --- a/res/shaders/ForwardPlus.slang +++ b/res/shaders/ForwardPlus.slang @@ -55,7 +55,7 @@ float4 fragmentMain( float3 result = float3(0, 0, 0); - for (int i = 0; i < 5; i++) + for (int i = 0; i < gLightEnv.numDirectionalLights; i++) { result += gLightEnv.directionalLights[i].illuminate(materialParams, brdf, viewDir); } @@ -72,6 +72,5 @@ float4 fragmentMain( result += pointLight.illuminate(materialParams, brdf, viewDir); } - - return float4(0, 1, 0, 1); + return float4(result, 1); } diff --git a/res/shaders/lib/Common.slang b/res/shaders/lib/Common.slang index ca14766..fd8fc74 100644 --- a/res/shaders/lib/Common.slang +++ b/res/shaders/lib/Common.slang @@ -1,4 +1,3 @@ -#pragma pack_matrix(column_major) const static float PI = 3.1415926535897932f; const static uint MAX_PARTICLES = 65536; const static uint BLOCK_SIZE = 8; diff --git a/src/Engine/Asset/AssetRegistry.cpp b/src/Engine/Asset/AssetRegistry.cpp index 43e4ce6..a2347a9 100644 --- a/src/Engine/Asset/AssetRegistry.cpp +++ b/src/Engine/Asset/AssetRegistry.cpp @@ -6,7 +6,7 @@ #include "MeshLoader.h" #include "Material/Material.h" #include "Graphics/Graphics.h" -#include "Graphics/WindowManager.h" +#include "Window/WindowManager.h" #include using namespace Seele; @@ -133,10 +133,14 @@ void AssetRegistry::registerMaterial(PMaterialAsset material) std::ofstream AssetRegistry::internalCreateWriteStream(const std::string& relativePath, std::ios_base::openmode openmode) { - return std::ofstream(rootFolder.generic_string().append(relativePath), openmode); + auto fullPath = rootFolder; + fullPath.append(relativePath); + return std::ofstream(fullPath.string(), openmode); } std::ifstream AssetRegistry::internalCreateReadStream(const std::string& relativePath, std::ios_base::openmode openmode) { - return std::ifstream(rootFolder.generic_string().append(relativePath), openmode); + auto fullPath = rootFolder; + fullPath.append(relativePath); + return std::ifstream(fullPath.string(), openmode); } diff --git a/src/Engine/Asset/MeshLoader.cpp b/src/Engine/Asset/MeshLoader.cpp index 311689e..12f98f4 100644 --- a/src/Engine/Asset/MeshLoader.cpp +++ b/src/Engine/Asset/MeshLoader.cpp @@ -44,39 +44,39 @@ void MeshLoader::loadMaterials(const aiScene* scene, Array& glob matCode["profile"] = "BlinnPhong"; //TODO: other shading models aiString texPath; //TODO make samplers based on used textures - matCode["params"]["texSampler"] = + matCode["params"]["textureSampler"] = { {"type", "SamplerState"} }; if(material->GetTexture(aiTextureType_DIFFUSE, 0, &texPath) == AI_SUCCESS) { - std::string texFilename = std::filesystem::path(texPath.C_Str()).stem().string(); + std::string texFilename = std::filesystem::path(texPath.C_Str()).replace_extension("asset").stem().string(); matCode["params"]["diffuseTexture"] = { {"type", "Texture2D"}, - {"default", texPath.C_Str()} + {"default", texFilename} }; - matCode["code"]["baseColor"] = "return diffuseTexture.Sample(textureSampler, geometry.texCoord).xyz;"; + matCode["code"]["baseColor"] = "return diffuseTexture.Sample(textureSampler, input.texCoords[0]).xyz;"; } if(material->GetTexture(aiTextureType_SPECULAR, 0, &texPath) == AI_SUCCESS) { - std::string texFilename = std::filesystem::path(texPath.C_Str()).stem().string(); + std::string texFilename = std::filesystem::path(texPath.C_Str()).replace_extension("asset").stem().string(); matCode["params"]["specularTexture"] = { {"type", "Texture2D"}, - {"default", texPath.C_Str()} + {"default", texFilename} }; - matCode["code"]["specular"] = "return specularTexture.Sample(textureSampler, geometry.texCoord).xyz;"; + matCode["code"]["specular"] = "return specularTexture.Sample(textureSampler, input.texCoords[0]).x;"; } if(material->GetTexture(aiTextureType_NORMALS, 0, &texPath) == AI_SUCCESS) { - std::string texFilename = std::filesystem::path(texPath.C_Str()).stem().string(); + std::string texFilename = std::filesystem::path(texPath.C_Str()).replace_extension("asset").stem().string(); matCode["params"]["normalTexture"] = { {"type", "Texture2D"}, - {"default", texPath.C_Str()} + {"default", texFilename} }; - matCode["code"]["normal"] = "return normalTexture.Sample(textureSampler, geometry.texCoord).xyz;"; + matCode["code"]["normal"] = "return normalTexture.Sample(textureSampler, input.texCoords[0]).xyz;"; } std::string outMatFilename = matCode["name"].get().append(".asset"); std::ofstream outMatFile = AssetRegistry::createWriteStream(outMatFilename); @@ -198,13 +198,14 @@ void MeshLoader::convertAssimpARGB(unsigned char* dst, aiTexel* src, uint32 numP dst[i * 4 + 3] = src[i].a; } } -void MeshLoader::loadTextures(const aiScene* scene, Gfx::PGraphics graphics, const std::filesystem::path& meshPath) +void MeshLoader::loadTextures(const aiScene* scene, Gfx::PGraphics graphics, const std::filesystem::path& meshDirectory) { for (uint32 i = 0; i < scene->mNumTextures; ++i) { aiTexture* tex = scene->mTextures[i]; auto texPath = std::filesystem::path(tex->mFilename.C_Str()); - auto texPngPath = meshPath.parent_path().append(texPath.filename().string()); + auto texPngPath = meshDirectory; + texPngPath.append(texPath.filename().string()); if(tex->mHeight == 0) { // already compressed, just dump it to the disk @@ -237,7 +238,7 @@ void MeshLoader::import(const std::filesystem::path &path) const aiScene *scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace); Array globalMaterials(scene->mNumMaterials); - loadTextures(scene, graphics, path); + loadTextures(scene, graphics, path.parent_path()); loadMaterials(scene, globalMaterials, graphics); Array globalMeshes(scene->mNumMeshes); diff --git a/src/Engine/Asset/TextureAsset.cpp b/src/Engine/Asset/TextureAsset.cpp index 753ff46..5cf1a2d 100644 --- a/src/Engine/Asset/TextureAsset.cpp +++ b/src/Engine/Asset/TextureAsset.cpp @@ -1,7 +1,7 @@ #include "TextureAsset.h" #include "Graphics/GraphicsResources.h" #include "Graphics/Graphics.h" -#include "Graphics/WindowManager.h" +#include "Window/WindowManager.h" #include #include @@ -28,6 +28,7 @@ TextureAsset::~TextureAsset() void TextureAsset::save() { //TODO: make this an actual file, not just a png wrapper + assert(false && "Editing textures is not yet supported"); } void TextureAsset::load() diff --git a/src/Engine/Asset/TextureAsset.h b/src/Engine/Asset/TextureAsset.h index a26a271..9edf7a3 100644 --- a/src/Engine/Asset/TextureAsset.h +++ b/src/Engine/Asset/TextureAsset.h @@ -23,6 +23,7 @@ public: } private: Gfx::PTexture texture; + friend class TextureLoader; }; DEFINE_REF(TextureAsset); } // namespace Seele diff --git a/src/Engine/Asset/TextureLoader.cpp b/src/Engine/Asset/TextureLoader.cpp index 7b41239..0eedb27 100644 --- a/src/Engine/Asset/TextureLoader.cpp +++ b/src/Engine/Asset/TextureLoader.cpp @@ -28,7 +28,7 @@ void TextureLoader::importAsset(const std::filesystem::path& filePath) PTextureAsset asset = new TextureAsset(assetFileName.replace_extension("asset").filename().generic_string()); asset->setStatus(Asset::Status::Loading); asset->setTexture(placeholderTexture); - AssetRegistry::get().textures[filePath.string()] = asset; + AssetRegistry::get().textures[asset->getFileName()] = asset; //futures.add(std::async(std::launch::async, [this, filePath, asset] () mutable { Gfx::PTexture2D texture = import(filePath); asset->setTexture(texture); @@ -45,8 +45,9 @@ Gfx::PTexture2D TextureLoader::import(const std::filesystem::path& path) { int x, y, n; unsigned char* data = stbi_load(path.string().c_str(), &x, &y, &n, 4); + TextureCreateInfo createInfo; - createInfo.format = Gfx::SE_FORMAT_R8G8B8A8_UINT; + createInfo.format = Gfx::SE_FORMAT_R8G8B8A8_SRGB; createInfo.resourceData.data = data; createInfo.resourceData.size = x * y * 4 * sizeof(unsigned char); createInfo.resourceData.owner = Gfx::QueueType::DEDICATED_TRANSFER; diff --git a/src/Engine/CMakeLists.txt b/src/Engine/CMakeLists.txt index 58ae880..8aee034 100644 --- a/src/Engine/CMakeLists.txt +++ b/src/Engine/CMakeLists.txt @@ -10,3 +10,5 @@ add_subdirectory(Graphics/) add_subdirectory(Material/) add_subdirectory(Math/) add_subdirectory(Scene/) +add_subdirectory(UI/) +add_subdirectory(Window/) diff --git a/src/Engine/Graphics/CMakeLists.txt b/src/Engine/Graphics/CMakeLists.txt index 20c9120..5a8dfee 100644 --- a/src/Engine/Graphics/CMakeLists.txt +++ b/src/Engine/Graphics/CMakeLists.txt @@ -13,24 +13,12 @@ target_sources(SeeleEngine RenderCore.cpp RenderMaterial.h RenderMaterial.cpp - RenderPath.h - RenderPath.cpp - SceneView.h - SceneView.cpp - SceneRenderPath.h - SceneRenderPath.cpp ShaderCompiler.h ShaderCompiler.cpp - View.h - View.cpp VertexShaderInput.h VertexShaderInput.cpp StaticMeshVertexInput.h - StaticMeshVertexInput.cpp - Window.cpp - Window.h - WindowManager.h - WindowManager.cpp) + StaticMeshVertexInput.cpp) add_subdirectory(RenderPass/) add_subdirectory(Vulkan/) \ No newline at end of file diff --git a/src/Engine/Graphics/GraphicsResources.h b/src/Engine/Graphics/GraphicsResources.h index 529b112..6a5171a 100644 --- a/src/Engine/Graphics/GraphicsResources.h +++ b/src/Engine/Graphics/GraphicsResources.h @@ -502,6 +502,8 @@ public: virtual void setKeyCallback(std::function callback) = 0; virtual void setMouseMoveCallback(std::function callback) = 0; virtual void setMouseButtonCallback(std::function callback) = 0; + virtual void setScrollCallback(std::function callback) = 0; + virtual void setFileCallback(std::function callback) = 0; SeFormat getSwapchainFormat() const { return pixelFormat; diff --git a/src/Engine/Graphics/RenderCore.cpp b/src/Engine/Graphics/RenderCore.cpp index 1c4e728..0440ab4 100644 --- a/src/Engine/Graphics/RenderCore.cpp +++ b/src/Engine/Graphics/RenderCore.cpp @@ -1,5 +1,5 @@ #include "RenderCore.h" -#include "SceneView.h" +#include "Window/SceneView.h" Seele::RenderCore::RenderCore() { diff --git a/src/Engine/Graphics/RenderCore.h b/src/Engine/Graphics/RenderCore.h index 7ac4157..26f9a5b 100644 --- a/src/Engine/Graphics/RenderCore.h +++ b/src/Engine/Graphics/RenderCore.h @@ -1,5 +1,5 @@ #pragma once -#include "WindowManager.h" +#include "Window/WindowManager.h" #include "Scene/Scene.h" namespace Seele { diff --git a/src/Engine/Graphics/RenderPass/BasePass.cpp b/src/Engine/Graphics/RenderPass/BasePass.cpp index f9f6561..ef40e38 100644 --- a/src/Engine/Graphics/RenderPass/BasePass.cpp +++ b/src/Engine/Graphics/RenderPass/BasePass.cpp @@ -1,8 +1,9 @@ #include "BasePass.h" #include "Graphics/Graphics.h" -#include "Graphics/Window.h" +#include "Window/Window.h" #include "Scene/Components/CameraComponent.h" #include "Scene/Actor/CameraActor.h" +#include "Math/Vector.h" using namespace Seele; @@ -162,7 +163,7 @@ void BasePass::beginFrame() viewParams.viewMatrix = source->getViewMatrix(); viewParams.projectionMatrix = source->getProjectionMatrix(); - viewParams.cameraPosition = Vector4(source->getTransform().getPosition(), 0); + viewParams.cameraPosition = Vector4(source->getCameraPosition(), 0); screenToViewParams.inverseProjectionMatrix = glm::inverse(viewParams.projectionMatrix); screenToViewParams.screenDimensions = Vector2(static_cast(viewport->getSizeX()), static_cast(viewport->getSizeY())); uniformUpdate.size = sizeof(ViewParameter); diff --git a/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.cpp b/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.cpp index e1f5d13..bf2f32f 100644 --- a/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.cpp +++ b/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.cpp @@ -89,6 +89,10 @@ void CmdBuffer::executeCommands(Array commands) auto command = commands[i].cast(); command->end(); executingCommands.add(command); + for(PDescriptorSet set : command->boundDescriptors) + { + set->setCurrentlyBound(this); + } cmdBuffers[i] = command->getHandle(); } vkCmdExecuteCommands(handle, cmdBuffers.size(), cmdBuffers.data()); @@ -112,7 +116,7 @@ void CmdBuffer::refreshFence() { command->reset(); } - + executingCommands.clear(); fence->reset(); } } diff --git a/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.h b/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.h index a289823..fced7b2 100644 --- a/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.h +++ b/src/Engine/Graphics/Vulkan/VulkanCommandBuffer.h @@ -92,6 +92,7 @@ public: private: PGraphicsPipeline pipeline; Array boundDescriptors; + friend class CmdBuffer; }; DEFINE_REF(SecondaryCmdBuffer); diff --git a/src/Engine/Graphics/Vulkan/VulkanDescriptorSets.cpp b/src/Engine/Graphics/Vulkan/VulkanDescriptorSets.cpp index 9931a52..d55d7e3 100644 --- a/src/Engine/Graphics/Vulkan/VulkanDescriptorSets.cpp +++ b/src/Engine/Graphics/Vulkan/VulkanDescriptorSets.cpp @@ -208,6 +208,7 @@ void DescriptorSet::writeChanges() if(currentlyBound != nullptr) { currentlyBound->getManager()->waitForCommands(currentlyBound); + currentlyBound = nullptr; } vkUpdateDescriptorSets(graphics->getDevice(), writeDescriptors.size(), writeDescriptors.data(), 0, nullptr); writeDescriptors.clear(); diff --git a/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h b/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h index 237cd54..ee6b5f3 100644 --- a/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h +++ b/src/Engine/Graphics/Vulkan/VulkanGraphicsResources.h @@ -324,10 +324,14 @@ public: virtual void setKeyCallback(std::function callback) override; virtual void setMouseMoveCallback(std::function callback) override; virtual void setMouseButtonCallback(std::function callback) override; + virtual void setScrollCallback(std::function callback) override; + virtual void setFileCallback(std::function callback) override; std::function keyCallback; std::function mouseMoveCallback; std::function mouseButtonCallback; + std::function scrollCallback; + std::function fileCallback; protected: void advanceBackBuffer(); void recreateSwapchain(const WindowCreateInfo &createInfo); diff --git a/src/Engine/Graphics/Vulkan/VulkanInitializer.cpp b/src/Engine/Graphics/Vulkan/VulkanInitializer.cpp index 537db16..fd23abd 100644 --- a/src/Engine/Graphics/Vulkan/VulkanInitializer.cpp +++ b/src/Engine/Graphics/Vulkan/VulkanInitializer.cpp @@ -768,15 +768,7 @@ VkPipelineShaderStageCreateInfo init::PipelineShaderStageCreateInfo(VkShaderStag #pragma warning(disable : 4100) VkBool32 Seele::Vulkan::debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, size_t location, int32_t code, const char *layerPrefix, const char *msg, void *userDataManager) { - if(flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) - { - //std::cerr << layerPrefix << ": " << msg << std::endl; - } - else - { - std::cerr << layerPrefix << ": " << msg << std::endl; - return VK_FALSE; - } + std::cerr << layerPrefix << ": " << msg << std::endl; return VK_FALSE; } #pragma warning(default : 4100) diff --git a/src/Engine/Graphics/Vulkan/VulkanViewport.cpp b/src/Engine/Graphics/Vulkan/VulkanViewport.cpp index 1be0f37..e20457e 100644 --- a/src/Engine/Graphics/Vulkan/VulkanViewport.cpp +++ b/src/Engine/Graphics/Vulkan/VulkanViewport.cpp @@ -14,6 +14,30 @@ void glfwKeyCallback(GLFWwindow* handle, int key, int scancode, int action, int window->keyCallback((KeyCode)key, (InputAction)action, (KeyModifier)modifier); } +void glfwMouseMoveCallback(GLFWwindow* handle, double xpos, double ypos) +{ + Window* window = (Window*)glfwGetWindowUserPointer(handle); + window->mouseMoveCallback(xpos, ypos); +} + +void glfwMouseButtonCallback(GLFWwindow* handle, int button, int action, int modifier) +{ + Window* window = (Window*)glfwGetWindowUserPointer(handle); + window->mouseButtonCallback((MouseButton)button, (InputAction)action, (KeyModifier)modifier); +} + +void glfwScrollCallback(GLFWwindow* handle, double xoffset, double yoffset) +{ + Window* window = (Window*)glfwGetWindowUserPointer(handle); + window->scrollCallback(xoffset, yoffset); +} + +void glfwFileCallback(GLFWwindow* handle, int count, const char** paths) +{ + Window* window = (Window*)glfwGetWindowUserPointer(handle); + window->fileCallback(count, paths); +} + Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo) : Gfx::Window(createInfo), graphics(graphics), instance(graphics->getInstance()), swapchain(VK_NULL_HANDLE), numSamples(createInfo.numSamples), pixelFormat(cast(createInfo.pixelFormat)) { @@ -23,6 +47,10 @@ Window::Window(PGraphics graphics, const WindowCreateInfo &createInfo) glfwSetWindowUserPointer(handle, this); glfwSetKeyCallback(handle, &glfwKeyCallback); + glfwSetCursorPosCallback(handle, &glfwMouseMoveCallback); + glfwSetMouseButtonCallback(handle, &glfwMouseButtonCallback); + glfwSetScrollCallback(handle, &glfwScrollCallback); + glfwSetDropCallback(handle, &glfwFileCallback); glfwCreateWindowSurface(instance, handle, nullptr, &surface); @@ -91,6 +119,16 @@ void Window::setMouseButtonCallback(std::function callback) +{ + scrollCallback = callback; +} + +void Window::setFileCallback(std::function callback) +{ + fileCallback = callback; +} + void Window::advanceBackBuffer() { VkResult res = VK_ERROR_OUT_OF_DATE_KHR; diff --git a/src/Engine/Graphics/Window.cpp b/src/Engine/Graphics/Window.cpp deleted file mode 100644 index 85cca4a..0000000 --- a/src/Engine/Graphics/Window.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "Window.h" -#include - -Seele::Window::Window(Gfx::PWindow handle) - : gfxHandle(handle) -{ -} - -Seele::Window::~Window() -{ -} - -void Seele::Window::addView(PView view) -{ - viewports.add(view); -} - -void Seele::Window::beginFrame() -{ - gfxHandle->beginFrame(); - for (auto view : viewports) - { - view->beginFrame(); - } -} - -void Seele::Window::render() -{ - for (auto view : viewports) - { - view->render(); - } -} - -void Seele::Window::endFrame() -{ - gfxHandle->endFrame(); - for (auto view : viewports) - { - view->endFrame(); - } -} - -Gfx::PWindow Seele::Window::getGfxHandle() -{ - return gfxHandle; -} - -void Window::setFocused(PView view) -{ - focusedView = view; - auto boundFunction = std::bind(&View::keyCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); - gfxHandle->setKeyCallback(boundFunction); -} diff --git a/src/Engine/Material/Material.cpp b/src/Engine/Material/Material.cpp index c6beb9f..c6cc5a0 100644 --- a/src/Engine/Material/Material.cpp +++ b/src/Engine/Material/Material.cpp @@ -2,7 +2,7 @@ #include "Asset/AssetRegistry.h" #include "Graphics/VertexShaderInput.h" #include "BRDF.h" -#include "Graphics/WindowManager.h" +#include "Window/WindowManager.h" #include #include #include @@ -60,8 +60,8 @@ void Material::compile() codeStream << "struct " << materialName << ": IMaterial {" << std::endl; uint32 uniformBufferOffset = 0; - uint32 bindingCounter = 1; // Uniform buffers are always binding 0 - layout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); + uint32 bindingCounter = 0; // Uniform buffers are always binding 0 + uniformBinding = -1; for(auto param : j["params"].items()) { std::string type = param.value()["type"].get(); @@ -70,6 +70,11 @@ void Material::compile() { PFloatParameter p = new FloatParameter(param.key(), uniformBufferOffset, 0); codeStream << "layout(offset = " << uniformBufferOffset << ")"; + if(uniformBinding == -1) + { + layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); + uniformBinding = bindingCounter++; + } uniformBufferOffset += 4; if(default != param.value().end()) { @@ -81,6 +86,11 @@ void Material::compile() { PVectorParameter p = new VectorParameter(param.key(), uniformBufferOffset, 0); codeStream << "layout(offset = " << uniformBufferOffset << ")"; + if(uniformBinding == -1) + { + layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER); + uniformBinding = bindingCounter++; + } uniformBufferOffset += 12; if(default != param.value().end()) { diff --git a/src/Engine/Material/MaterialAsset.cpp b/src/Engine/Material/MaterialAsset.cpp index 30f819e..d9227af 100644 --- a/src/Engine/Material/MaterialAsset.cpp +++ b/src/Engine/Material/MaterialAsset.cpp @@ -1,5 +1,5 @@ #include "MaterialAsset.h" -#include "Graphics/WindowManager.h" +#include "Window/WindowManager.h" using namespace Seele; @@ -41,7 +41,7 @@ void MaterialAsset::updateDescriptorData() if(uniformUpdate.size != 0) { uniformBuffer->updateContents(uniformUpdate); - descriptorSet->updateBuffer(0, uniformBuffer); + descriptorSet->updateBuffer(uniformBinding, uniformBuffer); } descriptorSet->writeChanges(); } diff --git a/src/Engine/Material/MaterialAsset.h b/src/Engine/Material/MaterialAsset.h index 6f16422..173ce81 100644 --- a/src/Engine/Material/MaterialAsset.h +++ b/src/Engine/Material/MaterialAsset.h @@ -32,6 +32,7 @@ protected: Gfx::PUniformBuffer uniformBuffer; uint32 uniformDataSize; uint8* uniformData; + int32 uniformBinding; }; DEFINE_REF(MaterialAsset); } // namespace Seele diff --git a/src/Engine/Material/MaterialInstance.cpp b/src/Engine/Material/MaterialInstance.cpp index efbf80b..33a678a 100644 --- a/src/Engine/Material/MaterialInstance.cpp +++ b/src/Engine/Material/MaterialInstance.cpp @@ -1,6 +1,6 @@ #include "MaterialInstance.h" #include "Material.h" -#include "Graphics/WindowManager.h" +#include "Window/WindowManager.h" using namespace Seele; diff --git a/src/Engine/Math/Transform.cpp b/src/Engine/Math/Transform.cpp index 812393e..0ac2f60 100644 --- a/src/Engine/Math/Transform.cpp +++ b/src/Engine/Math/Transform.cpp @@ -1,4 +1,5 @@ #include "Transform.h" +#include using namespace Seele; @@ -45,7 +46,7 @@ Vector Transform::inverseTransformPosition(const Vector &v) const } Matrix4 Transform::toMatrix() { - Matrix4 mat(1.0f); + Matrix4 mat; mat[3][0] = position.x; mat[3][1] = position.y; @@ -123,6 +124,11 @@ Vector Transform::getSafeScaleReciprocal(const Vector4 &inScale, float tolerance return safeReciprocalScale; } +Vector Transform::transformPosition(const Vector &v) const +{ + return Vector(glm::toMat4(rotation) * Vector4(v, 1)); +} + Vector Transform::getPosition() const { return Vector(position); @@ -158,7 +164,7 @@ bool Transform::equals(const Transform &other, float tolerance) void Transform::multiply(Transform *outTransform, const Transform *a, const Transform *b) { outTransform->rotation = b->rotation * a->rotation; - outTransform->position = b->position * (b->scale * a->position) + b->position; + outTransform->position = b->rotation * (b->scale * a->position) + b->position; outTransform->scale = b->scale * a->scale; } @@ -181,10 +187,9 @@ Transform &Transform::operator=(Transform &&other) return *this; } -Transform &Transform::operator*(const Transform &other) +Transform Transform::operator*(const Transform &other) const { Transform outTransform; multiply(&outTransform, this, &other); - *this = std::move(outTransform); - return *this; + return std::move(outTransform); } diff --git a/src/Engine/Math/Transform.h b/src/Engine/Math/Transform.h index bd18a59..35174a4 100644 --- a/src/Engine/Math/Transform.h +++ b/src/Engine/Math/Transform.h @@ -18,6 +18,7 @@ public: Vector inverseTransformPosition(const Vector &v) const; Matrix4 toMatrix(); static Vector getSafeScaleReciprocal(const Vector4 &inScale, float tolerance = 0.000000001f); + Vector transformPosition(const Vector &v) const; Vector getPosition() const; Quaternion getRotation() const; @@ -28,7 +29,7 @@ public: Transform &operator=(const Transform &other); Transform &operator=(Transform &&other); - Transform &operator*(const Transform &other); + Transform operator*(const Transform &other) const; private: Vector4 position; diff --git a/src/Engine/Scene/Actor/Actor.h b/src/Engine/Scene/Actor/Actor.h index cf29e13..76d6079 100644 --- a/src/Engine/Scene/Actor/Actor.h +++ b/src/Engine/Scene/Actor/Actor.h @@ -47,7 +47,6 @@ protected: PActor parent; Array children; PComponent rootComponent; - Transform transform; }; DEFINE_REF(Actor); } // namespace Seele \ No newline at end of file diff --git a/src/Engine/Scene/Actor/CameraActor.cpp b/src/Engine/Scene/Actor/CameraActor.cpp index c3cb95e..3b9d835 100644 --- a/src/Engine/Scene/Actor/CameraActor.cpp +++ b/src/Engine/Scene/Actor/CameraActor.cpp @@ -15,7 +15,7 @@ CameraActor::CameraActor() cameraComponent->setParent(sceneComponent); cameraComponent->setOwner(this); addWorldTranslation(Vector(0, 0, 50)); - addWorldRotation(Vector(0, -1, 0)); + addWorldRotation(Vector(0, -100, 0)); } CameraActor::~CameraActor() diff --git a/src/Engine/Scene/Components/CameraComponent.cpp b/src/Engine/Scene/Components/CameraComponent.cpp index 67e52f6..3c29868 100644 --- a/src/Engine/Scene/Components/CameraComponent.cpp +++ b/src/Engine/Scene/Components/CameraComponent.cpp @@ -1,5 +1,7 @@ #include "CameraComponent.h" +#include "Scene/Actor/Actor.h" #include +#include using namespace Seele; @@ -11,7 +13,7 @@ CameraComponent::CameraComponent() { distance = 50; rotationX = 0; - rotationY = -0.5f; + rotationY = -1.f; } CameraComponent::~CameraComponent() @@ -21,25 +23,26 @@ CameraComponent::~CameraComponent() void CameraComponent::mouseMove(float deltaX, float deltaY) { //0.01 mouse sensitivity - rotationX += deltaX/100.f; - rotationY += deltaY/100.f; + rotationX += deltaX/500.f; + rotationY += deltaY/500.f; rotationY = std::clamp(rotationY, -1.5f, 1.5f); - addWorldRotation(Vector(rotationX, rotationY, 0)); + getParent()->setWorldRotation(glm::rotate(glm::quat(), rotationX, Vector(0, 1, 0))); + getParent()->setWorldRotation(glm::rotate(glm::quat(), rotationY, Vector(1, 0, 0))); bNeedsViewBuild = true; } void CameraComponent::mouseScroll(double x) { - distance += static_cast(x); + distance -= static_cast(x); distance = std::max(distance, 1.f); - addWorldTranslation(Vector(0, 0, x)); + getParent()->addWorldTranslation(Vector(0, 0, x)); bNeedsViewBuild = true; } void CameraComponent::moveOrigin(float up) { originPoint.y += up; - addWorldTranslation(Vector(0, up, 0)); + getParent()->addWorldTranslation(Vector(0, up, 0)); bNeedsViewBuild = true; } diff --git a/src/Engine/Scene/Components/CameraComponent.h b/src/Engine/Scene/Components/CameraComponent.h index 5cbd4eb..4d19282 100644 --- a/src/Engine/Scene/Components/CameraComponent.h +++ b/src/Engine/Scene/Components/CameraComponent.h @@ -26,6 +26,14 @@ public: } return projectionMatrix; } + Vector getCameraPosition() + { + if(bNeedsViewBuild) + { + buildViewMatrix(); + } + return cameraPosition; + } void mouseMove(float deltaX, float deltaY); void mouseScroll(double x); void moveOrigin(float up); diff --git a/src/Engine/Scene/Components/Component.cpp b/src/Engine/Scene/Components/Component.cpp index 9b2abfb..acd4c71 100644 --- a/src/Engine/Scene/Components/Component.cpp +++ b/src/Engine/Scene/Components/Component.cpp @@ -6,6 +6,9 @@ using namespace Seele; Component::Component() { + relativeLocation = Vector(0); + relativeRotation = Vector(0); + relativeScale = Vector(1, 1, 1); } Component::~Component() { @@ -101,17 +104,17 @@ void Component::setRelativeScale(Vector scale) } void Component::addWorldTranslation(Vector translation) { - const Vector newWorldLocation = translation + transform.getPosition(); + const Vector newWorldLocation = translation + getTransform().getPosition(); setWorldLocation(newWorldLocation); } void Component::addWorldRotation(Vector rotation) { - const Quaternion newWorldRotation = toQuaternion(rotation) * transform.getRotation(); + const Quaternion newWorldRotation = toQuaternion(rotation) * getTransform().getRotation(); setWorldRotation(newWorldRotation); } void Component::addWorldRotation(Quaternion rotation) { - const Quaternion newWorldRotation = rotation * transform.getRotation(); + const Quaternion newWorldRotation = rotation * getTransform().getRotation(); setWorldRotation(newWorldRotation); } Transform Component::getTransform() const @@ -169,9 +172,13 @@ void Component::updateComponentTransform(Quaternion relativeRotationQuat) bComponentTransformClean = true; Transform newTransform; const Transform relTransform(relativeLocation, relativeRotationQuat, relativeScale); - if (parent != nullptr) + if(parent != nullptr) { - newTransform = parent->getTransform() * relTransform; + newTransform = relTransform * parent->getTransform(); + } + else + { + newTransform = relTransform; } bool bHasChanged = !getTransform().equals(newTransform); if (bHasChanged) diff --git a/src/Engine/Scene/Components/PrimitiveComponent.cpp b/src/Engine/Scene/Components/PrimitiveComponent.cpp index 99cf0d1..52c6dad 100644 --- a/src/Engine/Scene/Components/PrimitiveComponent.cpp +++ b/src/Engine/Scene/Components/PrimitiveComponent.cpp @@ -3,6 +3,7 @@ #include "Material/MaterialInstance.h" #include "Asset/MeshAsset.h" #include "Graphics/VertexShaderInput.h" +#include using namespace Seele; diff --git a/src/Engine/Scene/Scene.cpp b/src/Engine/Scene/Scene.cpp index a1d652c..8fdc082 100644 --- a/src/Engine/Scene/Scene.cpp +++ b/src/Engine/Scene/Scene.cpp @@ -10,6 +10,12 @@ using namespace Seele; Scene::Scene(Gfx::PGraphics graphics) : graphics(graphics) { + lightEnv.directionalLights[0].color = Vector4(1, 0, 0, 1); + lightEnv.directionalLights[0].direction = Vector4(1, 1, 0, 1); + lightEnv.directionalLights[0].intensity = Vector4(1, 1, 1, 1); + lightEnv.numDirectionalLights = 1; + lightEnv.numPointLights = 0; + srand(time(NULL)); } Scene::~Scene() diff --git a/src/Engine/Scene/Scene.h b/src/Engine/Scene/Scene.h index ac6eedc..97b566a 100644 --- a/src/Engine/Scene/Scene.h +++ b/src/Engine/Scene/Scene.h @@ -30,7 +30,7 @@ struct LightEnv { DirectionalLight directionalLights[MAX_DIRECTIONAL_LIGHTS]; PointLight pointLights[MAX_POINT_LIGHTS]; - uint32 numDirectionalLgiths; + uint32 numDirectionalLights; uint32 numPointLights; }; diff --git a/src/Engine/UI/CMakeLists.txt b/src/Engine/UI/CMakeLists.txt new file mode 100644 index 0000000..f059c5c --- /dev/null +++ b/src/Engine/UI/CMakeLists.txt @@ -0,0 +1,6 @@ +target_sources(SeeleEngine + PRIVATE + UIComponent.h + UIComponent.cpp + UIRenderPath.h + UIRenderPath.cpp) \ No newline at end of file diff --git a/src/Engine/UI/UIComponent.cpp b/src/Engine/UI/UIComponent.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Engine/UI/UIComponent.h b/src/Engine/UI/UIComponent.h new file mode 100644 index 0000000..63d1b7d --- /dev/null +++ b/src/Engine/UI/UIComponent.h @@ -0,0 +1,15 @@ +#pragma once +#include "MinimalEngine.h" +namespace Seele +{ +DECLARE_REF(UIRenderPath) +class UIComponent +{ +public: + UIComponent(PUIRenderPath renderer); + virtual ~UIComponent(); +private: + PUIRenderPath renderer; +}; +DEFINE_REF(UIComponent); +} // namespace Seele diff --git a/src/Engine/UI/UIRenderPath.cpp b/src/Engine/UI/UIRenderPath.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/Engine/UI/UIRenderPath.h b/src/Engine/UI/UIRenderPath.h new file mode 100644 index 0000000..1a53afa --- /dev/null +++ b/src/Engine/UI/UIRenderPath.h @@ -0,0 +1,19 @@ +#pragma once +#include "Window/RenderPath.h" +#include "UIComponent.h" + +namespace Seele +{ +class UIRenderPath : public RenderPath +{ +public: + UIRenderPath(); + virtual ~UIRenderPath(); + virtual void beginFrame(); + virtual void render(); + virtual void endFrame(); +private: +}; +DEFINE_REF(UIRenderPath); +} // namespace Seele + diff --git a/src/Engine/Window/CMakeLists.txt b/src/Engine/Window/CMakeLists.txt new file mode 100644 index 0000000..8562744 --- /dev/null +++ b/src/Engine/Window/CMakeLists.txt @@ -0,0 +1,16 @@ +target_sources(SeeleEngine + PRIVATE + InspectorView.h + InspectorView.cpp + RenderPath.h + RenderPath.cpp + SceneView.h + SceneView.cpp + SceneRenderPath.h + SceneRenderPath.cpp + View.h + View.cpp + Window.cpp + Window.h + WindowManager.h + WindowManager.cpp) diff --git a/src/Engine/Window/InspectorView.cpp b/src/Engine/Window/InspectorView.cpp new file mode 100644 index 0000000..7bba555 --- /dev/null +++ b/src/Engine/Window/InspectorView.cpp @@ -0,0 +1,26 @@ +#include "InspectorView.h" +using namespace Seele; + +InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo) + : View(graphics, window, createInfo) +{ +} + +InspectorView::~InspectorView() +{ +} + +void InspectorView::beginFrame() +{ + +} + +void InspectorView::render() +{ + +} + +void InspectorView::endFrame() +{ + +} diff --git a/src/Engine/Window/InspectorView.h b/src/Engine/Window/InspectorView.h new file mode 100644 index 0000000..00e7fe4 --- /dev/null +++ b/src/Engine/Window/InspectorView.h @@ -0,0 +1,19 @@ +#pragma once +#include "View.h" +#include "UI/UIRenderPath.h" + +namespace Seele +{ +class InspectorView : public View +{ +public: + InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo); + virtual ~InspectorView(); + virtual void beginFrame(); + virtual void render(); + virtual void endFrame(); + +private: + PUIComponent root; +}; +} // namespace Seele diff --git a/src/Engine/Graphics/RenderPath.cpp b/src/Engine/Window/RenderPath.cpp similarity index 89% rename from src/Engine/Graphics/RenderPath.cpp rename to src/Engine/Window/RenderPath.cpp index 7ea627a..787d68b 100644 --- a/src/Engine/Graphics/RenderPath.cpp +++ b/src/Engine/Window/RenderPath.cpp @@ -1,5 +1,5 @@ #include "RenderPath.h" -#include "GraphicsResources.h" +#include "Graphics/GraphicsResources.h" Seele::RenderPath::RenderPath(Gfx::PGraphics graphics, Gfx::PViewport target) : graphics(graphics), target(target) diff --git a/src/Engine/Graphics/RenderPath.h b/src/Engine/Window/RenderPath.h similarity index 93% rename from src/Engine/Graphics/RenderPath.h rename to src/Engine/Window/RenderPath.h index 6b57205..1fd0ad8 100644 --- a/src/Engine/Graphics/RenderPath.h +++ b/src/Engine/Window/RenderPath.h @@ -1,5 +1,5 @@ #pragma once -#include "Graphics.h" +#include "Graphics/Graphics.h" namespace Seele { //A renderpath is a general Renderer for a view. diff --git a/src/Engine/Graphics/SceneRenderPath.cpp b/src/Engine/Window/SceneRenderPath.cpp similarity index 100% rename from src/Engine/Graphics/SceneRenderPath.cpp rename to src/Engine/Window/SceneRenderPath.cpp diff --git a/src/Engine/Graphics/SceneRenderPath.h b/src/Engine/Window/SceneRenderPath.h similarity index 100% rename from src/Engine/Graphics/SceneRenderPath.h rename to src/Engine/Window/SceneRenderPath.h diff --git a/src/Engine/Graphics/SceneView.cpp b/src/Engine/Window/SceneView.cpp similarity index 51% rename from src/Engine/Graphics/SceneView.cpp rename to src/Engine/Window/SceneView.cpp index 1976ae5..b5c5095 100644 --- a/src/Engine/Graphics/SceneView.cpp +++ b/src/Engine/Window/SceneView.cpp @@ -4,7 +4,6 @@ #include "Window.h" #include "Scene/Actor/CameraActor.h" #include "Scene/Components/CameraComponent.h" -#include using namespace Seele; @@ -21,20 +20,60 @@ Seele::SceneView::~SceneView() { } +void SceneView::beginFrame() +{ + View::beginFrame(); + scene->tick(0);//TODO: update in separate thread +} + void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier modifier) { + if(action != InputAction::RELEASE) + { + if(code == KeyCode::KEY_W) + { + activeCamera->getCameraComponent()->moveOrigin(1); + } + if(code == KeyCode::KEY_S) + { + activeCamera->getCameraComponent()->moveOrigin(-1); + } + } } +static bool mouseDown = false; + void SceneView::mouseMoveCallback(double xPos, double yPos) { static double prevXPos = 0.0f, prevYPos = 0.0f; - double deltaX = xPos - prevXPos; - double deltaY = yPos - prevYPos; + double deltaX = prevXPos - xPos; + double deltaY = prevYPos - yPos; prevXPos = xPos; prevYPos = yPos; - activeCamera->getCameraComponent()->mouseMove(deltaX, deltaY); + if(mouseDown) + { + activeCamera->getCameraComponent()->mouseMove((float)deltaX, (float)deltaY); + } } void SceneView::mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) { + if(button == MouseButton::MOUSE_BUTTON_1 && action != InputAction::RELEASE) + { + mouseDown = true; + } + else + { + mouseDown = false; + } +} + +void SceneView::scrollCallback(double xOffset, double yOffset) +{ + activeCamera->getCameraComponent()->mouseScroll(yOffset); +} + +void SceneView::fileCallback(int count, const char** paths) +{ + } diff --git a/src/Engine/Graphics/SceneView.h b/src/Engine/Window/SceneView.h similarity index 79% rename from src/Engine/Graphics/SceneView.h rename to src/Engine/Window/SceneView.h index 12b7c84..886d070 100644 --- a/src/Engine/Graphics/SceneView.h +++ b/src/Engine/Window/SceneView.h @@ -9,6 +9,7 @@ class SceneView : public View public: SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo); ~SceneView(); + virtual void beginFrame(); PScene getScene() const { return scene; } private: PScene scene; @@ -16,6 +17,8 @@ private: 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 \ No newline at end of file diff --git a/src/Engine/Graphics/View.cpp b/src/Engine/Window/View.cpp similarity index 97% rename from src/Engine/Graphics/View.cpp rename to src/Engine/Window/View.cpp index fa30572..6a06bc6 100644 --- a/src/Engine/Graphics/View.cpp +++ b/src/Engine/Window/View.cpp @@ -1,3 +1,4 @@ +#pragma once #include "View.h" #include "Window.h" diff --git a/src/Engine/Graphics/View.h b/src/Engine/Window/View.h similarity index 78% rename from src/Engine/Graphics/View.h rename to src/Engine/Window/View.h index 2c2ae66..6d3649a 100644 --- a/src/Engine/Graphics/View.h +++ b/src/Engine/Window/View.h @@ -9,9 +9,9 @@ class View public: View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo); virtual ~View(); - void beginFrame(); - void render(); - void endFrame(); + virtual void beginFrame(); + virtual void render(); + virtual void endFrame(); void applyArea(URect area); void setFocused(); @@ -24,6 +24,8 @@ protected: virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0; virtual void mouseMoveCallback(double xPos, double yPos) = 0; virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifier modifier) = 0; + virtual void scrollCallback(double xOffset, double yOffset) = 0; + virtual void fileCallback(int count, const char** paths) = 0; friend class Window; }; diff --git a/src/Engine/Window/Window.cpp b/src/Engine/Window/Window.cpp new file mode 100644 index 0000000..ead6ca0 --- /dev/null +++ b/src/Engine/Window/Window.cpp @@ -0,0 +1,62 @@ +#include "Window.h" +#include + +Seele::Window::Window(Gfx::PWindow handle) + : gfxHandle(handle) +{ +} + +Seele::Window::~Window() +{ +} + +void Seele::Window::addView(PView view) +{ + viewports.add(view); +} + +void Seele::Window::beginFrame() +{ + gfxHandle->beginFrame(); + for (auto view : viewports) + { + view->beginFrame(); + } +} + +void Seele::Window::render() +{ + for (auto view : viewports) + { + view->render(); + } +} + +void Seele::Window::endFrame() +{ + gfxHandle->endFrame(); + for (auto view : viewports) + { + view->endFrame(); + } +} + +Gfx::PWindow Seele::Window::getGfxHandle() +{ + return gfxHandle; +} + +void Window::setFocused(PView view) +{ + focusedView = view; + auto keyFunction = std::bind(&View::keyCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); + auto mouseMoveFunction = std::bind(&View::mouseMoveCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2); + auto mouseButtonFunction = std::bind(&View::mouseButtonCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); + auto scrollFunction = std::bind(&View::scrollCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2); + auto fileFunction = std::bind(&View::fileCallback, view.getHandle(), std::placeholders::_1, std::placeholders::_2); + gfxHandle->setKeyCallback(keyFunction); + gfxHandle->setMouseMoveCallback(mouseMoveFunction); + gfxHandle->setMouseButtonCallback(mouseButtonFunction); + gfxHandle->setScrollCallback(scrollFunction); + gfxHandle->setFileCallback(fileFunction); +} diff --git a/src/Engine/Graphics/Window.h b/src/Engine/Window/Window.h similarity index 91% rename from src/Engine/Graphics/Window.h rename to src/Engine/Window/Window.h index 61f58f0..92410bd 100644 --- a/src/Engine/Graphics/Window.h +++ b/src/Engine/Window/Window.h @@ -1,5 +1,5 @@ #pragma once -#include "GraphicsResources.h" +#include "Graphics/GraphicsResources.h" #include "View.h" namespace Seele diff --git a/src/Engine/Graphics/WindowManager.cpp b/src/Engine/Window/WindowManager.cpp similarity index 96% rename from src/Engine/Graphics/WindowManager.cpp rename to src/Engine/Window/WindowManager.cpp index 88ce219..25910cf 100644 --- a/src/Engine/Graphics/WindowManager.cpp +++ b/src/Engine/Window/WindowManager.cpp @@ -1,5 +1,5 @@ #include "WindowManager.h" -#include "Vulkan/VulkanGraphics.h" +#include "Graphics/Vulkan/VulkanGraphics.h" Gfx::PGraphics WindowManager::graphics; diff --git a/src/Engine/Graphics/WindowManager.h b/src/Engine/Window/WindowManager.h similarity index 87% rename from src/Engine/Graphics/WindowManager.h rename to src/Engine/Window/WindowManager.h index ceab37d..0ae33e8 100644 --- a/src/Engine/Graphics/WindowManager.h +++ b/src/Engine/Window/WindowManager.h @@ -1,6 +1,6 @@ #pragma once -#include "GraphicsResources.h" -#include "Graphics.h" +#include "Graphics/GraphicsResources.h" +#include "Graphics/Graphics.h" #include "Containers/Array.h" #include "Window.h" diff --git a/src/Engine/main.cpp b/src/Engine/main.cpp index 7205ec7..cc3aaee 100644 --- a/src/Engine/main.cpp +++ b/src/Engine/main.cpp @@ -1,5 +1,5 @@ #include "Graphics/RenderCore.h" -#include "Graphics/SceneView.h" +#include "Window/SceneView.h" #include "Asset/AssetRegistry.h" using namespace Seele; int main() @@ -22,10 +22,11 @@ int main() PSceneView sceneView = new SceneView(core.getWindowManager()->getGraphics(), window, sceneViewInfo); window->addView(sceneView); sceneView->setFocused(); - AssetRegistry::init("D:\\Private\\Programming\\C++\\TestSeeleProject"); + AssetRegistry::init("D:\\Private\\Programming\\C++\\TestSeeleProject\\"); AssetRegistry::importFile("D:\\Private\\Programming\\Unreal Engine\\Assets\\Arissa\\Arissa.fbx"); PPrimitiveComponent arissa = new PrimitiveComponent(AssetRegistry::findMesh("Arissa")); arissa->addWorldTranslation(Vector(0, 0, 100)); + arissa->setWorldScale(Vector(0.1f, 0.1f, 0.1f)); sceneView->getScene()->addPrimitiveComponent(arissa); core.renderLoop(); core.shutdown();