diff --git a/CMakeLists.txt b/CMakeLists.txt index 07368b5..99e7d05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,14 +11,15 @@ set(IMGUI_DIR "${LIBS_DIR}/imgui") set(STB_DIR "${LIBS_DIR}/stb") set(ASSIMP_DIR "${LIBS_DIR}/assimp") -include_directories("${LIBS_DIR}") -find_package(OpenGL REQUIRED) # Executable project(space) set(CMAKE_CXX_STANDARD 17) add_executable(space ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) +target_include_directories(space PRIVATE "${LIBS_DIR}") +find_package(OpenGL REQUIRED) + # GLAD add_library(glad "${LIBS_DIR}/glad/src/glad.c") target_include_directories(glad PRIVATE "${LIBS_DIR}/glad/include") @@ -34,8 +35,10 @@ file(GLOB IMGUI_SOURCES "${IMGUI_DIR}/*.cpp" "${IMGUI_DIR}/*.h") # Assimp option(ASSIMP_BUILD_ASSIMP_TOOLS OFF) +option(ASSIMP_BUILD_ASSIMP_VIEW OFF) option(ASSIMP_BUILD_SAMPLES OFF) option(ASSIMP_BUILD_TESTS OFF) +option(ASSIMP_INSTALL OFF) add_subdirectory(${ASSIMP_DIR}) # Space diff --git a/README.md b/README.md index 6fb9c3d..1ee3768 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,19 @@ I'm mainly doing this to progress in c++ and OpenGL and because I always wanted ### Building +First, get the repo on your machine ```bash git clone https://github.com/PottierLoic/Space.git cd Space ``` +Get the submodules too +```bash +git submodule init +git submodule update +``` + +Build using the corresponding file ```bash # On Unix, you have to give permission. chmod +x ./build.sh @@ -43,18 +51,11 @@ cd build Space is using many libraries - GLFW - Graphic library -- Glad - OpenGl loader +- Glad - OpenGL loader - ImGui - C++ User interface -- GLM - Mathematics library +- GLM - Mathematics OpenGL library - Assimp - 3D model loader -Theses libraries are automatically cloned with this repository. -In case you still want to clone them: -```bash -git submodule init -git submodule update -``` - ## License This project is licensed under the [MIT License](LICENSE). diff --git a/awesomeface.png b/awesomeface.png deleted file mode 100644 index 9840caf..0000000 Binary files a/awesomeface.png and /dev/null differ diff --git a/container.jpg b/container.jpg deleted file mode 100644 index d07bee4..0000000 Binary files a/container.jpg and /dev/null differ diff --git a/include/Components/Component.hpp b/include/Components/Component.hpp index e838b7d..a5e696c 100644 --- a/include/Components/Component.hpp +++ b/include/Components/Component.hpp @@ -2,6 +2,9 @@ #include +#include "imgui/imgui_impl_glfw.h" +#include "imgui/imgui_stdlib.h" + class Component { public: Component(); diff --git a/include/Components/ModelRenderer.hpp b/include/Components/ModelRenderer.hpp new file mode 100644 index 0000000..6cd91fd --- /dev/null +++ b/include/Components/ModelRenderer.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "Components/Component.hpp" + +#include "Model/Model.hpp" + +// TODO: Review names +class ModelRenderer : Component { +public: + Model model = nullptr; + + /* Default constructor: Initializes a new empty ModelRenderer component. */ + ModelRenderer(); + + /* Destructor: Destroys the ModelRenderer component. Note: May not have additional functionality in this case. */ + ~ModelRenderer(); + + /* Display the ModelRenderer component properties in the inspector tab. */ + void display() override; +}; diff --git a/include/Components/Physic.hpp b/include/Components/Physic.hpp index b59a168..d0a79be 100644 --- a/include/Components/Physic.hpp +++ b/include/Components/Physic.hpp @@ -1,8 +1,5 @@ #pragma once -#include "imgui/imgui_impl_glfw.h" -#include "imgui/imgui_stdlib.h" - #include "Components/Component.hpp" class Physic : public Component { diff --git a/include/Components/Transform.hpp b/include/Components/Transform.hpp index 2470326..bf3954b 100644 --- a/include/Components/Transform.hpp +++ b/include/Components/Transform.hpp @@ -1,8 +1,5 @@ #pragma once -#include "imgui/imgui_impl_glfw.h" -#include "imgui/imgui_stdlib.h" - #include "Components/Component.hpp" #include "Vectors/Vector3.hpp" diff --git a/include/Mesh/Mesh.hpp b/include/Model/Mesh.hpp similarity index 87% rename from include/Mesh/Mesh.hpp rename to include/Model/Mesh.hpp index 45f71a6..0357d1b 100644 --- a/include/Mesh/Mesh.hpp +++ b/include/Model/Mesh.hpp @@ -4,8 +4,8 @@ #include "glad/glad.h" -#include "Mesh/Vertex.hpp" -#include "Mesh/Texture.hpp" +#include "Model/Vertex.hpp" +#include "Model/Texture.hpp" #include "Shader.hpp" class Mesh { diff --git a/include/Mesh/Model.hpp b/include/Model/Model.hpp similarity index 92% rename from include/Mesh/Model.hpp rename to include/Model/Model.hpp index 21d050f..edf4605 100644 --- a/include/Mesh/Model.hpp +++ b/include/Model/Model.hpp @@ -8,8 +8,8 @@ #include "assimp/postprocess.h" #include "stb_image.h" -#include "Mesh/Mesh.hpp" -#include "Mesh/Texture.hpp" +#include "Model/Mesh.hpp" +#include "Model/Texture.hpp" #include "Shader.hpp" unsigned int textureFromFile(const char *path, const std::string &directory, bool gamma = false); diff --git a/include/Mesh/Texture.hpp b/include/Model/Texture.hpp similarity index 100% rename from include/Mesh/Texture.hpp rename to include/Model/Texture.hpp diff --git a/include/Mesh/Vertex.hpp b/include/Model/Vertex.hpp similarity index 100% rename from include/Mesh/Vertex.hpp rename to include/Model/Vertex.hpp diff --git a/src/Components/ModelRenderer.cpp b/src/Components/ModelRenderer.cpp new file mode 100644 index 0000000..66cf37c --- /dev/null +++ b/src/Components/ModelRenderer.cpp @@ -0,0 +1,16 @@ +#include "Components/ModelRenderer.hpp" + +ModelRenderer::ModelRenderer() { + model = nullptr; +} + +ModelRenderer::~ModelRenderer() {} + +void ModelRenderer::display() { + if (ImGui::CollapsingHeader("Model Renderer")) { + ImGui::Text("Model"); + ImGui::SameLine(100); + // TODO: + // Should make a empty field to place the mesh from project explorer. + } +} diff --git a/src/Mesh/Mesh.cpp b/src/Model/Mesh.cpp similarity index 99% rename from src/Mesh/Mesh.cpp rename to src/Model/Mesh.cpp index 55dfc44..4b9f3cb 100644 --- a/src/Mesh/Mesh.cpp +++ b/src/Model/Mesh.cpp @@ -1,4 +1,4 @@ -#include "Mesh/Mesh.hpp" +#include "Model/Mesh.hpp" Mesh::Mesh(std::vector vertices, std::vector indices, std::vector textures) { this->vertices = vertices; diff --git a/src/Mesh/Model.cpp b/src/Model/Model.cpp similarity index 99% rename from src/Mesh/Model.cpp rename to src/Model/Model.cpp index a7ab838..aa4074d 100644 --- a/src/Mesh/Model.cpp +++ b/src/Model/Model.cpp @@ -1,4 +1,4 @@ -#include "Mesh/Model.hpp" +#include "Model/Model.hpp" Model::Model(const char *path) { loadModel(path); diff --git a/src/main.cpp b/src/main.cpp index fcbe29f..8e33a58 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,7 @@ #include "Menu.hpp" #include "Shader.hpp" #include "Camera.hpp" // maybe not stay here -#include "Mesh/Model.hpp" // maybe removed soon +#include "Model/Model.hpp" // maybe removed soon /* TODO: REMOVE */ /* DEBUG */ @@ -112,7 +112,7 @@ int main() { return -1; } glfwMakeContextCurrent(window); - glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); + // glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetFramebufferSizeCallback(window, framebufferSizeCallback); glfwSetCursorPosCallback(window, mouseCallback); glfwSetScrollCallback(window, scrollCallback);