Skip to content

Commit

Permalink
ModelRenderer / folder renaming / readme edit
Browse files Browse the repository at this point in the history
  • Loading branch information
PottierLoic committed Jan 3, 2024
1 parent 5942dc4 commit 064524b
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 25 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Binary file removed awesomeface.png
Binary file not shown.
Binary file removed container.jpg
Binary file not shown.
3 changes: 3 additions & 0 deletions include/Components/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#include <iostream>

#include "imgui/imgui_impl_glfw.h"
#include "imgui/imgui_stdlib.h"

class Component {
public:
Component();
Expand Down
20 changes: 20 additions & 0 deletions include/Components/ModelRenderer.hpp
Original file line number Diff line number Diff line change
@@ -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;
};
3 changes: 0 additions & 3 deletions include/Components/Physic.hpp
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions include/Components/Transform.hpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
4 changes: 2 additions & 2 deletions include/Mesh/Mesh.hpp → include/Model/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions include/Mesh/Model.hpp → include/Model/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions src/Components/ModelRenderer.cpp
Original file line number Diff line number Diff line change
@@ -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.
}
}
2 changes: 1 addition & 1 deletion src/Mesh/Mesh.cpp → src/Model/Mesh.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Mesh/Mesh.hpp"
#include "Model/Mesh.hpp"

Mesh::Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices, std::vector<Texture> textures) {
this->vertices = vertices;
Expand Down
2 changes: 1 addition & 1 deletion src/Mesh/Model.cpp → src/Model/Model.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "Mesh/Model.hpp"
#include "Model/Model.hpp"

Model::Model(const char *path) {
loadModel(path);
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 064524b

Please sign in to comment.