From 820d155dd025531bba54e072d2c7929a4e37ed78 Mon Sep 17 00:00:00 2001 From: Hack45 <45haha45@gmail.com> Date: Fri, 27 Jan 2023 00:36:15 +0100 Subject: [PATCH 1/2] Move files to source directory --- Renderer3D.vcxproj | 135 +++++++++--------- Renderer3D.vcxproj.filters | 132 ++++++++--------- Asset.cpp => src/Asset.cpp | 0 Asset.h => src/Asset.h | 0 Camera.h => src/Camera.h | 0 Color.cpp => src/Color.cpp | 0 Color.h => src/Color.h | 2 +- Component.cpp => src/Component.cpp | 0 Component.h => src/Component.h | 0 Editor.cpp => src/Editor.cpp | 0 Editor.h => src/Editor.h | 0 Engine.cpp => src/Engine.cpp | 6 +- Engine.h => src/Engine.h | 0 Entity.cpp => src/Entity.cpp | 0 Entity.h => src/Entity.h | 0 .../FluidSimulation.cpp | 0 FluidSimulation.h => src/FluidSimulation.h | 0 FrameBuffer.cpp => src/FrameBuffer.cpp | 0 FrameBuffer.h => src/FrameBuffer.h | 0 .../IEditorGUISelectable.h | 0 IO.cpp => src/IO.cpp | 0 IO.h => src/IO.h | 0 Input.cpp => src/Input.cpp | 0 Input.h => src/Input.h | 0 KeyCode.hpp => src/KeyCode.hpp | 0 LightSource.h => src/LightSource.h | 2 +- Material.cpp => src/Material.cpp | 0 Material.h => src/Material.h | 2 +- .../MaterialManager.hpp | 0 Mesh.cpp => src/Mesh.cpp | 0 Mesh.h => src/Mesh.h | 0 MeshRenderer.cpp => src/MeshRenderer.cpp | 0 MeshRenderer.h => src/MeshRenderer.h | 0 Model.cpp => src/Model.cpp | 0 Model.h => src/Model.h | 0 ModelManager.hpp => src/ModelManager.hpp | 0 ParticleSystem.cpp => src/ParticleSystem.cpp | 0 ParticleSystem.h => src/ParticleSystem.h | 0 .../RenderPass_Opaque.cpp | 0 .../RenderPass_Opaque.h | 0 .../RenderPass_ShadowMap.cpp | 0 .../RenderPass_ShadowMap.h | 0 .../RenderPass_Transparent.cpp | 0 .../RenderPass_Transparent.h | 0 .../RenderPass_VolumetricLight.cpp | 0 .../RenderPass_VolumetricLight.h | 0 Renderer.cpp => src/Renderer.cpp | 0 Renderer.h => src/Renderer.h | 0 Scene.cpp => src/Scene.cpp | 0 Scene.h => src/Scene.h | 0 Shader.cpp => src/Shader.cpp | 0 Shader.h => src/Shader.h | 4 +- ShaderManager.hpp => src/ShaderManager.hpp | 0 TestRender.hpp => src/TestRender.hpp | 0 Texture.cpp => src/Texture.cpp | 0 Texture.h => src/Texture.h | 0 TextureManager.hpp => src/TextureManager.hpp | 0 Transform.cpp => src/Transform.cpp | 0 Transform.h => src/Transform.h | 0 .../VolumetricCloud.cpp | 0 VolumetricCloud.h => src/VolumetricCloud.h | 0 glad.c => src/glad.c | 0 logger.cpp => src/logger.cpp | 0 logger.h => src/logger.h | 0 main.cpp => src/main.cpp | 0 65 files changed, 144 insertions(+), 139 deletions(-) rename Asset.cpp => src/Asset.cpp (100%) rename Asset.h => src/Asset.h (100%) rename Camera.h => src/Camera.h (100%) rename Color.cpp => src/Color.cpp (100%) rename Color.h => src/Color.h (97%) rename Component.cpp => src/Component.cpp (100%) rename Component.h => src/Component.h (100%) rename Editor.cpp => src/Editor.cpp (100%) rename Editor.h => src/Editor.h (100%) rename Engine.cpp => src/Engine.cpp (99%) rename Engine.h => src/Engine.h (100%) rename Entity.cpp => src/Entity.cpp (100%) rename Entity.h => src/Entity.h (100%) rename FluidSimulation.cpp => src/FluidSimulation.cpp (100%) rename FluidSimulation.h => src/FluidSimulation.h (100%) rename FrameBuffer.cpp => src/FrameBuffer.cpp (100%) rename FrameBuffer.h => src/FrameBuffer.h (100%) rename IEditorGUISelectable.h => src/IEditorGUISelectable.h (100%) rename IO.cpp => src/IO.cpp (100%) rename IO.h => src/IO.h (100%) rename Input.cpp => src/Input.cpp (100%) rename Input.h => src/Input.h (100%) rename KeyCode.hpp => src/KeyCode.hpp (100%) rename LightSource.h => src/LightSource.h (99%) rename Material.cpp => src/Material.cpp (100%) rename Material.h => src/Material.h (99%) rename MaterialManager.hpp => src/MaterialManager.hpp (100%) rename Mesh.cpp => src/Mesh.cpp (100%) rename Mesh.h => src/Mesh.h (100%) rename MeshRenderer.cpp => src/MeshRenderer.cpp (100%) rename MeshRenderer.h => src/MeshRenderer.h (100%) rename Model.cpp => src/Model.cpp (100%) rename Model.h => src/Model.h (100%) rename ModelManager.hpp => src/ModelManager.hpp (100%) rename ParticleSystem.cpp => src/ParticleSystem.cpp (100%) rename ParticleSystem.h => src/ParticleSystem.h (100%) rename RenderPass_Opaque.cpp => src/RenderPass_Opaque.cpp (100%) rename RenderPass_Opaque.h => src/RenderPass_Opaque.h (100%) rename RenderPass_ShadowMap.cpp => src/RenderPass_ShadowMap.cpp (100%) rename RenderPass_ShadowMap.h => src/RenderPass_ShadowMap.h (100%) rename RenderPass_Transparent.cpp => src/RenderPass_Transparent.cpp (100%) rename RenderPass_Transparent.h => src/RenderPass_Transparent.h (100%) rename RenderPass_VolumetricLight.cpp => src/RenderPass_VolumetricLight.cpp (100%) rename RenderPass_VolumetricLight.h => src/RenderPass_VolumetricLight.h (100%) rename Renderer.cpp => src/Renderer.cpp (100%) rename Renderer.h => src/Renderer.h (100%) rename Scene.cpp => src/Scene.cpp (100%) rename Scene.h => src/Scene.h (100%) rename Shader.cpp => src/Shader.cpp (100%) rename Shader.h => src/Shader.h (98%) rename ShaderManager.hpp => src/ShaderManager.hpp (100%) rename TestRender.hpp => src/TestRender.hpp (100%) rename Texture.cpp => src/Texture.cpp (100%) rename Texture.h => src/Texture.h (100%) rename TextureManager.hpp => src/TextureManager.hpp (100%) rename Transform.cpp => src/Transform.cpp (100%) rename Transform.h => src/Transform.h (100%) rename VolumetricCloud.cpp => src/VolumetricCloud.cpp (100%) rename VolumetricCloud.h => src/VolumetricCloud.h (100%) rename glad.c => src/glad.c (100%) rename logger.cpp => src/logger.cpp (100%) rename logger.h => src/logger.h (100%) rename main.cpp => src/main.cpp (100%) diff --git a/Renderer3D.vcxproj b/Renderer3D.vcxproj index 3023875..dd25ca6 100644 --- a/Renderer3D.vcxproj +++ b/Renderer3D.vcxproj @@ -70,13 +70,18 @@ - .\include;$(IncludePath) + C:\Users\Hack45\source\repos\Renderer3D\include;.\include;$(IncludePath);C:\Users\Hack45\source\repos\Renderer3D\include .\lib;$(LibraryPath) + $(PublicIncludeDirectories) .\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); .\lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) + + $(PublicIncludeDirectories) + C:\Users\Hack45\source\repos\Renderer3D\include;$(VC_IncludePath);$(WindowsSDK_IncludePath);;C:\Users\Hack45\source\repos\Renderer3D\include + Level3 @@ -137,52 +142,53 @@ - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + @@ -191,36 +197,35 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Renderer3D.vcxproj.filters b/Renderer3D.vcxproj.filters index 9ec950f..c016253 100644 --- a/Renderer3D.vcxproj.filters +++ b/Renderer3D.vcxproj.filters @@ -60,61 +60,61 @@ - + Archivos de origen - + Archivos de origen - + Archivos de origen\Util - + Include - + Archivos de origen - + Archivos de origen - + Archivos de origen\Util - + Archivos de origen - + Archivos de origen - + Archivos de origen - + Archivos de origen\Managers - + Archivos de origen - + Archivos de origen - + Archivos de origen\Components - + Archivos de origen\Components - + Archivos de origen - + Archivos de origen\Components - + Archivos de origen - + Archivos de origen @@ -135,31 +135,31 @@ Include\imgui - + Archivos de origen - + Archivos de origen - + Archivos de origen - + Archivos de origen - + Archivos de origen - + Archivos de origen\RenderPass - + Archivos de origen\RenderPass - + Archivos de origen\RenderPass - + Archivos de origen\RenderPass @@ -176,85 +176,82 @@ Include - + Archivos de encabezado - - Include - - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado\Util - + Archivos de encabezado\Util - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado\Util - + Archivos de encabezado - + Archivos de encabezado\Util - + Archivos de encabezado\Managers - + Archivos de encabezado\Managers - + Archivos de encabezado\Managers - + Archivos de encabezado\Managers - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado\Components - + Archivos de encabezado\Components - + Archivos de encabezado\Managers - + Archivos de encabezado\Components - + Archivos de encabezado - + Archivos de encabezado @@ -281,33 +278,36 @@ Include\imgui - + Archivos de encabezado\Interfaces - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado - + Archivos de encabezado\RenderPass - + Archivos de encabezado\RenderPass - + Archivos de encabezado\RenderPass - + Archivos de encabezado\RenderPass + + Archivos de encabezado + diff --git a/Asset.cpp b/src/Asset.cpp similarity index 100% rename from Asset.cpp rename to src/Asset.cpp diff --git a/Asset.h b/src/Asset.h similarity index 100% rename from Asset.h rename to src/Asset.h diff --git a/Camera.h b/src/Camera.h similarity index 100% rename from Camera.h rename to src/Camera.h diff --git a/Color.cpp b/src/Color.cpp similarity index 100% rename from Color.cpp rename to src/Color.cpp diff --git a/Color.h b/src/Color.h similarity index 97% rename from Color.h rename to src/Color.h index 4cc2d31..9ad1f6b 100644 --- a/Color.h +++ b/src/Color.h @@ -1,5 +1,5 @@ #pragma once -#include "include/glm/glm.hpp" +#include "glm/glm.hpp" struct Color { Color(float r, float g, float b, float a) { diff --git a/Component.cpp b/src/Component.cpp similarity index 100% rename from Component.cpp rename to src/Component.cpp diff --git a/Component.h b/src/Component.h similarity index 100% rename from Component.h rename to src/Component.h diff --git a/Editor.cpp b/src/Editor.cpp similarity index 100% rename from Editor.cpp rename to src/Editor.cpp diff --git a/Editor.h b/src/Editor.h similarity index 100% rename from Editor.h rename to src/Editor.h diff --git a/Engine.cpp b/src/Engine.cpp similarity index 99% rename from Engine.cpp rename to src/Engine.cpp index a3789c3..a8682a4 100644 --- a/Engine.cpp +++ b/src/Engine.cpp @@ -4,9 +4,9 @@ #include #include -#include "include/imgui/imgui.h" -#include "include/imgui/examples/imgui_impl_glfw.h" -#include "include/imgui/examples/imgui_impl_opengl3.h" +#include "imgui/imgui.h" +#include "imgui/examples/imgui_impl_glfw.h" +#include "imgui/examples/imgui_impl_opengl3.h" #include #include diff --git a/Engine.h b/src/Engine.h similarity index 100% rename from Engine.h rename to src/Engine.h diff --git a/Entity.cpp b/src/Entity.cpp similarity index 100% rename from Entity.cpp rename to src/Entity.cpp diff --git a/Entity.h b/src/Entity.h similarity index 100% rename from Entity.h rename to src/Entity.h diff --git a/FluidSimulation.cpp b/src/FluidSimulation.cpp similarity index 100% rename from FluidSimulation.cpp rename to src/FluidSimulation.cpp diff --git a/FluidSimulation.h b/src/FluidSimulation.h similarity index 100% rename from FluidSimulation.h rename to src/FluidSimulation.h diff --git a/FrameBuffer.cpp b/src/FrameBuffer.cpp similarity index 100% rename from FrameBuffer.cpp rename to src/FrameBuffer.cpp diff --git a/FrameBuffer.h b/src/FrameBuffer.h similarity index 100% rename from FrameBuffer.h rename to src/FrameBuffer.h diff --git a/IEditorGUISelectable.h b/src/IEditorGUISelectable.h similarity index 100% rename from IEditorGUISelectable.h rename to src/IEditorGUISelectable.h diff --git a/IO.cpp b/src/IO.cpp similarity index 100% rename from IO.cpp rename to src/IO.cpp diff --git a/IO.h b/src/IO.h similarity index 100% rename from IO.h rename to src/IO.h diff --git a/Input.cpp b/src/Input.cpp similarity index 100% rename from Input.cpp rename to src/Input.cpp diff --git a/Input.h b/src/Input.h similarity index 100% rename from Input.h rename to src/Input.h diff --git a/KeyCode.hpp b/src/KeyCode.hpp similarity index 100% rename from KeyCode.hpp rename to src/KeyCode.hpp diff --git a/LightSource.h b/src/LightSource.h similarity index 99% rename from LightSource.h rename to src/LightSource.h index 6a4d786..42ab37a 100644 --- a/LightSource.h +++ b/src/LightSource.h @@ -1,6 +1,6 @@ #pragma once #include -#include "include/glm/glm.hpp" +#include "glm/glm.hpp" #include "logger.h" diff --git a/Material.cpp b/src/Material.cpp similarity index 100% rename from Material.cpp rename to src/Material.cpp diff --git a/Material.h b/src/Material.h similarity index 99% rename from Material.h rename to src/Material.h index 450ecc4..2835026 100644 --- a/Material.h +++ b/src/Material.h @@ -4,7 +4,7 @@ #include -#include "include/glm/glm.hpp" +#include "glm/glm.hpp" #include #include "Shader.h" diff --git a/MaterialManager.hpp b/src/MaterialManager.hpp similarity index 100% rename from MaterialManager.hpp rename to src/MaterialManager.hpp diff --git a/Mesh.cpp b/src/Mesh.cpp similarity index 100% rename from Mesh.cpp rename to src/Mesh.cpp diff --git a/Mesh.h b/src/Mesh.h similarity index 100% rename from Mesh.h rename to src/Mesh.h diff --git a/MeshRenderer.cpp b/src/MeshRenderer.cpp similarity index 100% rename from MeshRenderer.cpp rename to src/MeshRenderer.cpp diff --git a/MeshRenderer.h b/src/MeshRenderer.h similarity index 100% rename from MeshRenderer.h rename to src/MeshRenderer.h diff --git a/Model.cpp b/src/Model.cpp similarity index 100% rename from Model.cpp rename to src/Model.cpp diff --git a/Model.h b/src/Model.h similarity index 100% rename from Model.h rename to src/Model.h diff --git a/ModelManager.hpp b/src/ModelManager.hpp similarity index 100% rename from ModelManager.hpp rename to src/ModelManager.hpp diff --git a/ParticleSystem.cpp b/src/ParticleSystem.cpp similarity index 100% rename from ParticleSystem.cpp rename to src/ParticleSystem.cpp diff --git a/ParticleSystem.h b/src/ParticleSystem.h similarity index 100% rename from ParticleSystem.h rename to src/ParticleSystem.h diff --git a/RenderPass_Opaque.cpp b/src/RenderPass_Opaque.cpp similarity index 100% rename from RenderPass_Opaque.cpp rename to src/RenderPass_Opaque.cpp diff --git a/RenderPass_Opaque.h b/src/RenderPass_Opaque.h similarity index 100% rename from RenderPass_Opaque.h rename to src/RenderPass_Opaque.h diff --git a/RenderPass_ShadowMap.cpp b/src/RenderPass_ShadowMap.cpp similarity index 100% rename from RenderPass_ShadowMap.cpp rename to src/RenderPass_ShadowMap.cpp diff --git a/RenderPass_ShadowMap.h b/src/RenderPass_ShadowMap.h similarity index 100% rename from RenderPass_ShadowMap.h rename to src/RenderPass_ShadowMap.h diff --git a/RenderPass_Transparent.cpp b/src/RenderPass_Transparent.cpp similarity index 100% rename from RenderPass_Transparent.cpp rename to src/RenderPass_Transparent.cpp diff --git a/RenderPass_Transparent.h b/src/RenderPass_Transparent.h similarity index 100% rename from RenderPass_Transparent.h rename to src/RenderPass_Transparent.h diff --git a/RenderPass_VolumetricLight.cpp b/src/RenderPass_VolumetricLight.cpp similarity index 100% rename from RenderPass_VolumetricLight.cpp rename to src/RenderPass_VolumetricLight.cpp diff --git a/RenderPass_VolumetricLight.h b/src/RenderPass_VolumetricLight.h similarity index 100% rename from RenderPass_VolumetricLight.h rename to src/RenderPass_VolumetricLight.h diff --git a/Renderer.cpp b/src/Renderer.cpp similarity index 100% rename from Renderer.cpp rename to src/Renderer.cpp diff --git a/Renderer.h b/src/Renderer.h similarity index 100% rename from Renderer.h rename to src/Renderer.h diff --git a/Scene.cpp b/src/Scene.cpp similarity index 100% rename from Scene.cpp rename to src/Scene.cpp diff --git a/Scene.h b/src/Scene.h similarity index 100% rename from Scene.h rename to src/Scene.h diff --git a/Shader.cpp b/src/Shader.cpp similarity index 100% rename from Shader.cpp rename to src/Shader.cpp diff --git a/Shader.h b/src/Shader.h similarity index 98% rename from Shader.h rename to src/Shader.h index 7e0ef4e..7875f13 100644 --- a/Shader.h +++ b/src/Shader.h @@ -3,11 +3,11 @@ #ifndef SHADER_H #define SHADER_H -#include "include/glad.h" +#include "glad.h" #include "logger.h" -#include "include/glm/glm.hpp" +#include "glm/glm.hpp" #include #include diff --git a/ShaderManager.hpp b/src/ShaderManager.hpp similarity index 100% rename from ShaderManager.hpp rename to src/ShaderManager.hpp diff --git a/TestRender.hpp b/src/TestRender.hpp similarity index 100% rename from TestRender.hpp rename to src/TestRender.hpp diff --git a/Texture.cpp b/src/Texture.cpp similarity index 100% rename from Texture.cpp rename to src/Texture.cpp diff --git a/Texture.h b/src/Texture.h similarity index 100% rename from Texture.h rename to src/Texture.h diff --git a/TextureManager.hpp b/src/TextureManager.hpp similarity index 100% rename from TextureManager.hpp rename to src/TextureManager.hpp diff --git a/Transform.cpp b/src/Transform.cpp similarity index 100% rename from Transform.cpp rename to src/Transform.cpp diff --git a/Transform.h b/src/Transform.h similarity index 100% rename from Transform.h rename to src/Transform.h diff --git a/VolumetricCloud.cpp b/src/VolumetricCloud.cpp similarity index 100% rename from VolumetricCloud.cpp rename to src/VolumetricCloud.cpp diff --git a/VolumetricCloud.h b/src/VolumetricCloud.h similarity index 100% rename from VolumetricCloud.h rename to src/VolumetricCloud.h diff --git a/glad.c b/src/glad.c similarity index 100% rename from glad.c rename to src/glad.c diff --git a/logger.cpp b/src/logger.cpp similarity index 100% rename from logger.cpp rename to src/logger.cpp diff --git a/logger.h b/src/logger.h similarity index 100% rename from logger.h rename to src/logger.h diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp From 2c3b3358d3599dc504d580fb45986ce6095eea6e Mon Sep 17 00:00:00 2001 From: Hack45 <45haha45@gmail.com> Date: Sun, 4 Aug 2024 19:37:26 +0200 Subject: [PATCH 2/2] CMake and fix runetime errors --- CMakeLists.txt | 11 ++ src/CMakeLists.txt | 211 +++++++++++++++++++++++++++++++++ src/Camera.h | 9 +- src/Editor.cpp | 5 +- src/Editor.h | 4 +- src/Engine.cpp | 41 ++++--- src/FrameBuffer.h | 2 +- src/IO.cpp | 26 +++- src/LightSource.h | 12 +- src/MeshRenderer.h | 2 + src/Model.cpp | 3 +- src/ModelManager.hpp | 25 ++-- src/RenderPass_Opaque.cpp | 3 - src/RenderPass_ShadowMap.cpp | 17 ++- src/RenderPass_Transparent.cpp | 3 - src/Scene.cpp | 4 +- src/Transform.cpp | 2 +- src/Transform.h | 7 +- src/main.cpp | 2 +- 19 files changed, 323 insertions(+), 66 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c2575b2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.0.0) +project(3D_Renderer VERSION 0.1.0 LANGUAGES C CXX) + +message(STATUS "Generating Engine") + +find_package(OpenGL REQUIRED COMPONENTS OpenGL) +set(ENGINE_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include) +set(ENGINE_LIB ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CXX_STANDARD c++17) +add_subdirectory(src) +message(STATUS "Finished Generating Engine") \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..a59e4e0 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,211 @@ + +message(STATUS "-- Generating Core Engine") + +set(3D_Renderer_core_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/Asset.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Color.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Component.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Editor.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Engine.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Entity.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FluidSimulation.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FrameBuffer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Input.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/IO.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/logger.cpp + # ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Material.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Mesh.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/MeshRenderer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Model.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ParticleSystem.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Renderer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_Opaque.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_ShadowMap.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_Transparent.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_VolumetricLight.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Scene.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Shader.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Texture.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Transform.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/VolumetricCloud.cpp +) + +set(3D_Renderer_core_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/Asset.h + ${CMAKE_CURRENT_SOURCE_DIR}/Camera.h + ${CMAKE_CURRENT_SOURCE_DIR}/Color.h + ${CMAKE_CURRENT_SOURCE_DIR}/Component.h + ${CMAKE_CURRENT_SOURCE_DIR}/Editor.h + ${CMAKE_CURRENT_SOURCE_DIR}/Engine.h + ${CMAKE_CURRENT_SOURCE_DIR}/Entity.h + ${CMAKE_CURRENT_SOURCE_DIR}/FluidSimulation.h + ${CMAKE_CURRENT_SOURCE_DIR}/FrameBuffer.h + ${CMAKE_CURRENT_SOURCE_DIR}/IEditorGUISelectable.h + ${CMAKE_CURRENT_SOURCE_DIR}/Input.h + ${CMAKE_CURRENT_SOURCE_DIR}/IO.h + ${CMAKE_CURRENT_SOURCE_DIR}/KeyCode.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/LightSource.h + ${CMAKE_CURRENT_SOURCE_DIR}/logger.h + ${CMAKE_CURRENT_SOURCE_DIR}/Material.h + ${CMAKE_CURRENT_SOURCE_DIR}/MaterialManager.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/Mesh.h + ${CMAKE_CURRENT_SOURCE_DIR}/MeshRenderer.h + ${CMAKE_CURRENT_SOURCE_DIR}/Model.h + ${CMAKE_CURRENT_SOURCE_DIR}/ModelManager.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/ParticleSystem.h + ${CMAKE_CURRENT_SOURCE_DIR}/Renderer.h + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_Opaque.h + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_ShadowMap.h + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_Transparent.h + ${CMAKE_CURRENT_SOURCE_DIR}/RenderPass_VolumetricLight.h + ${CMAKE_CURRENT_SOURCE_DIR}/Scene.h + ${CMAKE_CURRENT_SOURCE_DIR}/Shader.h + ${CMAKE_CURRENT_SOURCE_DIR}/ShaderManager.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/TestRender.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/Texture.h + ${CMAKE_CURRENT_SOURCE_DIR}/TextureManager.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/Transform.h + ${CMAKE_CURRENT_SOURCE_DIR}/VolumetricCloud.h +) + +set(3D_Renderer_imgui + ${ENGINE_INCLUDE}/imgui/imconfig.h + ${ENGINE_INCLUDE}/imgui/imgui_demo.cpp + ${ENGINE_INCLUDE}/imgui/imgui_draw.cpp + ${ENGINE_INCLUDE}/imgui/imgui_internal.h + ${ENGINE_INCLUDE}/imgui/imgui_widgets.cpp + ${ENGINE_INCLUDE}/imgui/imgui.cpp + ${ENGINE_INCLUDE}/imgui/imgui.h + ${ENGINE_INCLUDE}/imgui/imstb_rectpack.h + ${ENGINE_INCLUDE}/imgui/imstb_textedit.h + ${ENGINE_INCLUDE}/imgui/imstb_truetype.h + ${ENGINE_INCLUDE}/imgui/examples/imgui_impl_glfw.cpp + ${ENGINE_INCLUDE}/imgui/examples/imgui_impl_glfw.h + ${ENGINE_INCLUDE}/imgui/examples/imgui_impl_opengl3.h + ${ENGINE_INCLUDE}/imgui/examples/imgui_impl_opengl3.cpp +) + +set(3D_Renderer_assimp + ${ENGINE_INCLUDE}/assimp/aabb.h + ${ENGINE_INCLUDE}/assimp/ai_assert.h + ${ENGINE_INCLUDE}/assimp/anim.h + ${ENGINE_INCLUDE}/assimp/BaseImporter.h + ${ENGINE_INCLUDE}/assimp/Bitmap.h + ${ENGINE_INCLUDE}/assimp/BlobIOSystem.h + ${ENGINE_INCLUDE}/assimp/ByteSwapper.h + ${ENGINE_INCLUDE}/assimp/camera.h + ${ENGINE_INCLUDE}/assimp/cexport.h + ${ENGINE_INCLUDE}/assimp/cfileio.h + ${ENGINE_INCLUDE}/assimp/cimport.h + ${ENGINE_INCLUDE}/assimp/color4.h + ${ENGINE_INCLUDE}/assimp/color4.inl + ${ENGINE_INCLUDE}/assimp/config.h + ${ENGINE_INCLUDE}/assimp/config.h.in + ${ENGINE_INCLUDE}/assimp/CreateAnimMesh.h + ${ENGINE_INCLUDE}/assimp/DefaultIOStream.h + ${ENGINE_INCLUDE}/assimp/DefaultIOSystem.h + ${ENGINE_INCLUDE}/assimp/DefaultLogger.hpp + ${ENGINE_INCLUDE}/assimp/Defines.h + ${ENGINE_INCLUDE}/assimp/defs.h + ${ENGINE_INCLUDE}/assimp/Exceptional.h + ${ENGINE_INCLUDE}/assimp/Exporter.hpp + ${ENGINE_INCLUDE}/assimp/fast_atof.h + ${ENGINE_INCLUDE}/assimp/GenericProperty.h + ${ENGINE_INCLUDE}/assimp/Hash.h + ${ENGINE_INCLUDE}/assimp/Importer.hpp + ${ENGINE_INCLUDE}/assimp/importerdesc.h + ${ENGINE_INCLUDE}/assimp/IOStream.hpp + ${ENGINE_INCLUDE}/assimp/IOStreamBuffer.h + ${ENGINE_INCLUDE}/assimp/IOSystem.hpp + ${ENGINE_INCLUDE}/assimp/irrXMLWrapper.h + ${ENGINE_INCLUDE}/assimp/light.h + ${ENGINE_INCLUDE}/assimp/LineSplitter.h + ${ENGINE_INCLUDE}/assimp/LogAux.h + ${ENGINE_INCLUDE}/assimp/Logger.hpp + ${ENGINE_INCLUDE}/assimp/LogStream.hpp + ${ENGINE_INCLUDE}/assimp/Macros.h + ${ENGINE_INCLUDE}/assimp/material.h + ${ENGINE_INCLUDE}/assimp/material.inl + ${ENGINE_INCLUDE}/assimp/MathFunctions.h + ${ENGINE_INCLUDE}/assimp/matrix3x3.h + ${ENGINE_INCLUDE}/assimp/matrix3x3.inl + ${ENGINE_INCLUDE}/assimp/matrix4x4.h + ${ENGINE_INCLUDE}/assimp/matrix4x4.inl + ${ENGINE_INCLUDE}/assimp/MemoryIOWrapper.h + ${ENGINE_INCLUDE}/assimp/mesh.h + ${ENGINE_INCLUDE}/assimp/metadata.h + ${ENGINE_INCLUDE}/assimp/NullLogger.hpp + ${ENGINE_INCLUDE}/assimp/ParsingUtils.h + ${ENGINE_INCLUDE}/assimp/pbrmaterial.h + ${ENGINE_INCLUDE}/assimp/postprocess.h + ${ENGINE_INCLUDE}/assimp/Profiler.h + ${ENGINE_INCLUDE}/assimp/ProgressHandler.hpp + ${ENGINE_INCLUDE}/assimp/qnan.h + ${ENGINE_INCLUDE}/assimp/quaternion.h + ${ENGINE_INCLUDE}/assimp/quaternion.inl + ${ENGINE_INCLUDE}/assimp/RemoveComments.h + ${ENGINE_INCLUDE}/assimp/scene.h + ${ENGINE_INCLUDE}/assimp/SceneCombiner.h + ${ENGINE_INCLUDE}/assimp/SGSpatialSort.h + ${ENGINE_INCLUDE}/assimp/SkeletonMeshBuilder.h + ${ENGINE_INCLUDE}/assimp/SmoothingGroups.h + ${ENGINE_INCLUDE}/assimp/SmoothingGroups.inl + ${ENGINE_INCLUDE}/assimp/SpatialSort.h + ${ENGINE_INCLUDE}/assimp/StandardShapes.h + ${ENGINE_INCLUDE}/assimp/StreamReader.h + ${ENGINE_INCLUDE}/assimp/StreamWriter.h + ${ENGINE_INCLUDE}/assimp/StringComparison.h + ${ENGINE_INCLUDE}/assimp/StringUtils.h + ${ENGINE_INCLUDE}/assimp/Subdivision.h + ${ENGINE_INCLUDE}/assimp/texture.h + ${ENGINE_INCLUDE}/assimp/TinyFormatter.h + ${ENGINE_INCLUDE}/assimp/types.h + ${ENGINE_INCLUDE}/assimp/vector2.h + ${ENGINE_INCLUDE}/assimp/vector2.inl + ${ENGINE_INCLUDE}/assimp/vector3.h + ${ENGINE_INCLUDE}/assimp/vector3.inl + ${ENGINE_INCLUDE}/assimp/version.h + ${ENGINE_INCLUDE}/assimp/Vertex.h + ${ENGINE_INCLUDE}/assimp/XMLTools.h + ${ENGINE_INCLUDE}/assimp/ZipArchiveIOSystem.h +) + +message(STATUS "stb_image: ${ENGINE_INCLUDE}/stb_image.h") + +set(3D_Renderer_FILES + ${3D_Renderer_assimp} + ${3D_Renderer_imgui} + ${ENGINE_INCLUDE}/stb_image.h + ${ENGINE_INCLUDE}/glad.h + ${CMAKE_CURRENT_SOURCE_DIR}/glad.c + ${ENGINE_INCLUDE}/KHR/khrplatform.h + ${3D_Renderer_core_SOURCES} + ${3D_Renderer_core_HEADERS} +) + +# Add the 3D_Renderer library to the project +message(STATUS "-- Adding Core Engine Library") +add_library(3D_Renderer ${3D_Renderer_FILES}) + +target_include_directories(3D_Renderer PUBLIC + ${ENGINE_INCLUDE} +) + +target_link_libraries(3D_Renderer PRIVATE + ${ENGINE_LIB}/glfw3.lib + ${ENGINE_LIB}/assimp-vc142-mtd.lib +) + +# target_compile_options(3D_Renderer PRIVATE --std=c++17) + +add_executable(3D_Renderer_exe ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${3D_Renderer_FILES}) + +target_include_directories(3D_Renderer_exe PUBLIC + ${ENGINE_INCLUDE} +) + +target_link_libraries(3D_Renderer_exe PRIVATE + ${ENGINE_LIB}/glfw3.lib + ${ENGINE_LIB}/assimp-vc142-mtd.lib +) \ No newline at end of file diff --git a/src/Camera.h b/src/Camera.h index 69879b4..e713da7 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -2,7 +2,7 @@ #define CAMERA_H #include "glad.h" -#include "glm/glm.hpp"" +#include "glm/glm.hpp" #include "glm/gtc/matrix_transform.hpp" #include @@ -46,7 +46,8 @@ class Camera float ortoFrustrum_Horizontal = 250; float ortoFrustrum_Vertical = 250; - float near = 1.f, far = 1000; + float nearClip = 1.f; + float farClip = 1000; float aspectRatio = 800 / 450; // constructor with vectors @@ -78,9 +79,9 @@ class Camera glm::mat4 GetProjectionMatrix() { if (isOrtographic) - return glm::ortho(-(ortoFrustrum_Horizontal / 2), ortoFrustrum_Horizontal / 2, -(ortoFrustrum_Vertical / 2), ortoFrustrum_Vertical / 2, near, far); + return glm::ortho(-(ortoFrustrum_Horizontal / 2), ortoFrustrum_Horizontal / 2, -(ortoFrustrum_Vertical / 2), ortoFrustrum_Vertical / 2, nearClip, farClip); else - return glm::perspective(glm::radians(Zoom), aspectRatio, near, far); + return glm::perspective(glm::radians(Zoom), aspectRatio, nearClip, farClip); } glm::mat4 GetViewProjectionMatrix() { diff --git a/src/Editor.cpp b/src/Editor.cpp index 495ee9b..dbfbe51 100644 --- a/src/Editor.cpp +++ b/src/Editor.cpp @@ -422,7 +422,8 @@ namespace Engine ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", deltatime * 1000.f, 1.f / (deltatime)); ImGui::End(); - ImGuiWindowFlags windowsFlags = ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; + // ImGuiWindowFlags windowsFlags = ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; + ImGuiWindowFlags windowsFlags = ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoCollapse; //Resources if (ImGui::Begin("Resources", NULL, windowsFlags)) { @@ -458,7 +459,7 @@ namespace Engine //Properties if (ImGui::Begin("Properties", NULL, windowsFlags)) { - if(selected) + if(selected != nullptr) selected->drawEditorGUI_Properties(); } ImGui::End(); diff --git a/src/Editor.h b/src/Editor.h index dcfd773..c2d24b2 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -44,7 +44,9 @@ namespace Engine //Variables----------------------------------- //Methods------------------------------------- - Editor() {} + Editor() { + selected = nullptr; + } Editor(Editor const&) = delete; Editor& operator=(Editor const&) = delete; ~Editor() {}; diff --git a/src/Engine.cpp b/src/Engine.cpp index a8682a4..6c1689f 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -159,11 +159,15 @@ namespace Engine screenRendered_fbo = new FrameBuffer(800 * 2, 450 * 2, FrameBuffer::FrameType_Depth | FrameBuffer::FrameType_Color, 0, GL_RGB); + m_model = nullptr; + m_model2 = nullptr; + log_message(log_level_e::LOG_INFO, "Engine Initialized\n"); return 0; } void Engine::Start() { + log_message(log_level_e::LOG_DEBUG, "\n\n\n--------------------------Starting Engine------------------------\n"); //m_model = new Model("./rcs/sponza/Sponza.gltf", "Backpack"); m_model = modelManager->getModel("Sponza",false, true);//Geting and loading model @@ -174,6 +178,8 @@ namespace Engine //IO::printEngineRCSFiles(); //IO::printProjectFiles(); + + log_message(log_level_e::LOG_DEBUG, "\n\n\n--------------------------End Engine Starting------------------------\n"); } void Engine::mainLoop() { @@ -237,16 +243,16 @@ namespace Engine //------------Particle - ParticleSystem* particleSys = new ParticleSystem(glm::vec3(0.f, 2.f, 0.f), glm::vec3(10.f, 10.f, 10.f), 1, 2); + // ParticleSystem* particleSys = new ParticleSystem(glm::vec3(0.f, 2.f, 0.f), glm::vec3(10.f, 10.f, 10.f), 1, 2); //------------Fluid - FluidSimulation* fluidSim = new FluidSimulation(64, 64, 64); + // FluidSimulation* fluidSim = new FluidSimulation(64, 64, 64); //------------Cloud - VolumetricCloud* vCloud = new VolumetricCloud(64, 64, 64); - vCloud->setChanelResolution(10,0,0,0); - vCloud->GenerateVoronoiPoints(); - vCloud->GenerateClouds(); + // VolumetricCloud* vCloud = new VolumetricCloud(64, 64, 64); + // vCloud->setChanelResolution(10,0,0,0); + // vCloud->GenerateVoronoiPoints(); + // vCloud->GenerateClouds(); RP_shadowMap->setScene(scene); RP_shadowMap->setMainCamera(&cam); @@ -357,7 +363,7 @@ namespace Engine if(showShadowmapCam) Renderer::drawFullScreenQuad(RP_shadowMap->getFBO()->colorTextureID()); - //drawScene(&cam); + // drawScene(&cam); //particleSys->Draw(&cam); //fluidSim->Draw(&cam); @@ -461,22 +467,22 @@ namespace Engine shader->setVector("lightPos", lightPos); - shader->setFloat("far_plane", cascadeCam0->far); + shader->setFloat("far_plane", cascadeCam0->farClip); glViewport(0, 0, res, res); renderPass(cascadeCam0, shader); //glClear(GL_DEPTH_BUFFER_BIT); - shader->setFloat("far_plane", cascadeCam1->far); + shader->setFloat("far_plane", cascadeCam1->farClip); glViewport(res, 0, res, res); renderPass(cascadeCam1, shader); - shader->setFloat("far_plane", cascadeCam2->far); + shader->setFloat("far_plane", cascadeCam2->farClip); glViewport(res * 2, 0, res, res); renderPass(cascadeCam2, shader); - shader->setFloat("far_plane", cascadeCam3->far); + shader->setFloat("far_plane", cascadeCam3->farClip); glViewport(res * 3, 0, res, res); renderPass(cascadeCam3, shader); } @@ -504,9 +510,6 @@ namespace Engine view = cam->GetViewMatrix(); - float near = .01f; - float far = 1000.0f; - projection *= cam->GetProjectionMatrix(); shader->setMat4("view", view); @@ -540,8 +543,8 @@ namespace Engine ImGui::DragFloat("Horizontal", &cCam0.ortoFrustrum_Horizontal); ImGui::DragFloat("Vertical", &cCam0.ortoFrustrum_Vertical); - ImGui::DragFloat("Near", &cCam0.near); - ImGui::DragFloat("Far", &cCam0.far); + ImGui::DragFloat("Near", &cCam0.nearClip); + ImGui::DragFloat("Far", &cCam0.farClip); ImGui::Spacing(); ImGui::Spacing(); @@ -629,7 +632,7 @@ namespace Engine screenRendered_fbo->bind(true);//world render pass--------------------------------------------------------- - glClearColor(.5,.5,.5, 1); + glClearColor(.25, .25, .25, 1); glClear(GL_COLOR_BUFFER_BIT); glClearColor(1, 1, 1, 1); @@ -679,8 +682,8 @@ namespace Engine volumetricLightShader->setInt("marchingSteps", volumetricLight_steps); volumetricLightShader->setFloat("marchingDistance", 100); volumetricLightShader->setVector("cameraDirection", cam->Front); - volumetricLightShader->setFloat("farPlane", cam->far); - volumetricLightShader->setFloat("nearPlane", cam->near); + volumetricLightShader->setFloat("farPlane", cam->farClip); + volumetricLightShader->setFloat("nearPlane", cam->nearClip); volumetricLightShader->setFloat("intensity", volumetricLight_intensity); volumetricLightShader->setFloat("airDensity", volumetricLight_density); diff --git a/src/FrameBuffer.h b/src/FrameBuffer.h index 20f4009..2d685a6 100644 --- a/src/FrameBuffer.h +++ b/src/FrameBuffer.h @@ -2,7 +2,7 @@ #ifndef FRAMEBUFFER_H #define FRAMEBUFFER_H -#include "glad.h"; +#include "glad.h" namespace Engine { diff --git a/src/IO.cpp b/src/IO.cpp index c9ece99..6f3f251 100644 --- a/src/IO.cpp +++ b/src/IO.cpp @@ -56,9 +56,21 @@ namespace Engine texturePaths.clear(); modelPaths.clear(); + std::cout << "Active directory: " << fs::current_path() << std::endl; + std::cout << "Scanning files..." << std::endl; //Scan Engine resources Path - for (auto& p : fs::recursive_directory_iterator("./rcs")) { + std::filesystem::recursive_directory_iterator rcs_directory_iterator; + try{ + rcs_directory_iterator = fs::recursive_directory_iterator("./rcs"); + } + catch (const std::exception& e) { + std::cout << "Error Scanning Engine RCS: " << e.what() << std::endl; + throw e; + } + std::cout << "Scanning Engine RCS..." << std::endl; + for (auto& p : rcs_directory_iterator) { std::string path = p.path().string(); + // std::cout << path << '\n'; std::string extension = p.path().extension().string(); std::string nameExt = p.path().filename().string();//name with extension std::string name = nameExt.substr(0, nameExt.size() - extension.size());//name without extension @@ -91,8 +103,18 @@ namespace Engine } //Scan Project Path - for (auto& p : fs::recursive_directory_iterator(projectPath)) { + std::filesystem::recursive_directory_iterator project_directory_iterator; + try{ + project_directory_iterator = fs::recursive_directory_iterator(projectPath); + } + catch (const std::exception& e) { + std::cout << "Error Scanning Project Files: " << e.what() << std::endl; + throw e; + } + std::cout << "Scanning Project Files..." << std::endl; + for (auto& p : project_directory_iterator) { std::string path = p.path().string(); + // std::cout << path << '\n'; std::string extension = p.path().extension().string(); std::string nameExt = p.path().filename().string();//name with extension std::string name = nameExt.substr(0, nameExt.size() - extension.size());//name without extension diff --git a/src/LightSource.h b/src/LightSource.h index 42ab37a..4f2405f 100644 --- a/src/LightSource.h +++ b/src/LightSource.h @@ -14,9 +14,9 @@ enum LightSrcType { NONE = 0, - DIRECTIONAL = 1, - SPOT = 2, - POINT = 3 + DIRECTIONAL_LIGHT = 1, + SPOT_LIGHT = 2, + POINT_LIGHT = 3 }; class LightSource @@ -80,7 +80,7 @@ class LightSource_Directional : public LightSource { } LightSrcType getLightSrcType()const { - return LightSrcType::DIRECTIONAL; + return LightSrcType::DIRECTIONAL_LIGHT; } float yaw = 0,pitch = 0; @@ -117,7 +117,7 @@ class LightSource_Spot : public LightSource { void setPosition(const glm::vec3& position) { m_pos = position; } LightSrcType getLightSrcType()const { - return LightSrcType::SPOT; + return LightSrcType::SPOT_LIGHT; } glm::vec3 m_dir; @@ -157,7 +157,7 @@ class LightSource_Point : public LightSource { } LightSrcType getLightSrcType()const { - return LightSrcType::POINT; + return LightSrcType::POINT_LIGHT; } glm::vec3 m_pos; diff --git a/src/MeshRenderer.h b/src/MeshRenderer.h index a4f3834..b451b06 100644 --- a/src/MeshRenderer.h +++ b/src/MeshRenderer.h @@ -18,6 +18,8 @@ namespace Engine public: MeshRenderer() { name = "MeshRenderer"; + m_mesh = nullptr; + m_material = nullptr; } void Init(Mesh* mesh, Material* material) { m_mesh = mesh; diff --git a/src/Model.cpp b/src/Model.cpp index 3a1d63b..dfc1b3b 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -12,6 +12,7 @@ namespace Engine m_flipUvs = flipUVs; m_numMeshes = 0; m_meshes = nullptr; + importer = nullptr; } Model::~Model() @@ -32,7 +33,7 @@ namespace Engine float iniTime = glfwGetTime(); - if (importer)//delete importer if it already has one + if (importer != nullptr) //delete importer if it already has one realeseLoadingResources(); importer = new Assimp::Importer(); diff --git a/src/ModelManager.hpp b/src/ModelManager.hpp index cf16146..495a9a0 100644 --- a/src/ModelManager.hpp +++ b/src/ModelManager.hpp @@ -27,31 +27,40 @@ namespace Engine std::vector< std::pair>* models = IO::getModelPaths(); - for (std::pair modelPath : *(models)) + std::cout << "Adding models:" << std::endl; + std::cout << " Number of models: " << models->size() << std::endl; + for (std::pair modelPath : *(models)){ + std::cout << " Adding model: " << modelPath.first << std::endl; AddModel(modelPath.first, modelPath.second, loadModels); + } } void AddModel(const std::string& modelName, const std::string& modelPath, bool loadModel = false) { + std::cout << " Model path: " << modelPath << std::endl; modelsPath[modelName] = modelPath; if (loadModel) { - models[modelName] = new Model(modelsPath[modelName].c_str(), modelName);//load model - models[modelName]->loadFile(); + std::cout << " Loading model: " << modelPath << std::endl; + // TODO: Window not opening when this code is discommented!!!!!! + // maybe it's crashing on startup + // TODO: When the program crashes no error is shown (windows crash popup)!!!!!!!!! + // models[modelName] = new Model(modelsPath[modelName].c_str(), modelName); //load model + // models[modelName]->loadFile(); } } Model* getModel(const std::string& modelName, bool loadModel = true, bool flipUVs = false) { if (models.find(modelName) == models.end()) - {//Shader not found + { //Model not found - //Trying to load the shader + //Trying to load the model if (modelsPath.find(modelName) == modelsPath.end()) { - //Shader path not found - log_error("ERROR::SHADER_MANAGER::Shader file not found."); + //Model path not found + log_error("ERROR::MODEL_MANAGER::Model file not found."); modelsPath[modelName] = "_ERROR_MODEL"; return nullptr; } else { - //Loading shader + //Loading model models[modelName] = new Model(modelsPath[modelName].c_str(), modelName, flipUVs); if(loadModel) models[modelName]->loadFile(); diff --git a/src/RenderPass_Opaque.cpp b/src/RenderPass_Opaque.cpp index bda4031..dd51d06 100644 --- a/src/RenderPass_Opaque.cpp +++ b/src/RenderPass_Opaque.cpp @@ -69,9 +69,6 @@ namespace Engine view = cam->GetViewMatrix(); - float near = .01f; - float far = 1000.0f; - projection *= cam->GetProjectionMatrix(); shader->setMat4("view", view); diff --git a/src/RenderPass_ShadowMap.cpp b/src/RenderPass_ShadowMap.cpp index 26ad37c..5a4b2e9 100644 --- a/src/RenderPass_ShadowMap.cpp +++ b/src/RenderPass_ShadowMap.cpp @@ -39,8 +39,8 @@ namespace Engine ImGui::DragFloat("Horizontal", &auxCams[0].ortoFrustrum_Horizontal); ImGui::DragFloat("Vertical", &auxCams[0].ortoFrustrum_Vertical); - ImGui::DragFloat("Near", &auxCams[0].near); - ImGui::DragFloat("Far", &auxCams[0].far); + ImGui::DragFloat("Near", &auxCams[0].nearClip); + ImGui::DragFloat("Far", &auxCams[0].farClip); ImGui::Spacing(); ImGui::Spacing(); @@ -62,19 +62,19 @@ namespace Engine shader->setVector("lightPos", lightPos); - shader->setFloat("far_plane", auxCams[0].far); + shader->setFloat("far_plane", auxCams[0].farClip); glViewport(0, 0, res, res); renderPass(&auxCams[0]); - shader->setFloat("far_plane", auxCams[1].far); + shader->setFloat("far_plane", auxCams[1].farClip); glViewport(res, 0, res, res); renderPass(&auxCams[1]); - shader->setFloat("far_plane", auxCams[2].far); + shader->setFloat("far_plane", auxCams[2].farClip); glViewport(res * 2, 0, res, res); renderPass(&auxCams[2]); - shader->setFloat("far_plane", auxCams[0].far); + shader->setFloat("far_plane", auxCams[0].farClip); glViewport(res * 3, 0, res, res); renderPass(&auxCams[0]); } @@ -87,9 +87,6 @@ namespace Engine view = cam->GetViewMatrix(); - float near = .01f; - float far = 1000.0f; - projection *= cam->GetProjectionMatrix(); shader->setMat4("view", view); @@ -101,7 +98,7 @@ namespace Engine for (auto entity : scene->entities) { - if (!entity->meshRenderer.m_material || !entity->meshRenderer.m_mesh)//doesn't have material or mesh + if (entity->meshRenderer.m_material == nullptr || entity->meshRenderer.m_mesh == nullptr)//doesn't have material or mesh continue; glm::mat4 model = entity->transform.globalSpace(); diff --git a/src/RenderPass_Transparent.cpp b/src/RenderPass_Transparent.cpp index fc1dd8c..9054dfb 100644 --- a/src/RenderPass_Transparent.cpp +++ b/src/RenderPass_Transparent.cpp @@ -52,9 +52,6 @@ namespace Engine view = cam->GetViewMatrix(); - float near = .01f; - float far = 1000.0f; - projection *= cam->GetProjectionMatrix(); shader->setMat4("view", view); diff --git a/src/Scene.cpp b/src/Scene.cpp index 3903cb8..cc31234 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -247,11 +247,11 @@ namespace Engine Entity* Scene::loadModel2Scene(Model* model) { - if (!model) { + if (model == nullptr) { log_error("ERROR::SCENE::LOAD_MODEL_MATERIALS: model is null"); return nullptr; } - else if (!model->m_scene) { + else if (model->m_scene == nullptr) { log_error(("ERROR::SCENE::LOAD_MODEL_MATERIALS: model " + model->assetName + " not loaded.").c_str()); return nullptr; } diff --git a/src/Transform.cpp b/src/Transform.cpp index 40aa8b4..db89d4a 100644 --- a/src/Transform.cpp +++ b/src/Transform.cpp @@ -18,7 +18,7 @@ namespace Engine } glm::mat4 Transform::globalSpace() const { - if (parent) + if (parent != nullptr) return parent->globalSpace() * localSpace(); else//is root return localSpace(); diff --git a/src/Transform.h b/src/Transform.h index 7680d52..e3947f2 100644 --- a/src/Transform.h +++ b/src/Transform.h @@ -15,6 +15,9 @@ namespace Engine { public: //Methods------------------------------------- + Transform(){ + parent = nullptr; + } glm::mat4 localSpace()const; glm::mat4 globalSpace()const; glm::vec3 globalPosition()const; @@ -32,8 +35,8 @@ namespace Engine char* entityName; //Local transform info - glm::vec3 m_position; - glm::vec3 m_eulerAngle;//TODO: Change euler angles t quaternions + glm::vec3 m_position = glm::vec3(0.f); + glm::vec3 m_eulerAngle = glm::vec3(0.f);//TODO: Change euler angles t quaternions glm::vec3 m_scale = glm::vec3(1.f); private: diff --git a/src/main.cpp b/src/main.cpp index 3c73a68..092623b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ int main() { if (error < 0) { - system("pause"); + // system("pause"); return error; }