Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,56 @@ set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(glfw)

# --- 3. Find System Packages ---
# --- 3. Fetch Assimp ---
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ASSIMP_INSTALL OFF CACHE BOOL "" FORCE)
set(ASSIMP_WARNINGS_AS_ERRORS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ZLIB ON CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_MINIZIP ON CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
assimp
GIT_REPOSITORY https://github.com/assimp/assimp.git
GIT_TAG v5.4.3
)
FetchContent_MakeAvailable(assimp)
if(TARGET assimp)
target_include_directories(assimp PRIVATE
${assimp_SOURCE_DIR}/contrib/zlib/contrib/minizip
)
target_sources(assimp PRIVATE
${assimp_SOURCE_DIR}/contrib/zlib/contrib/minizip/ioapi.c
${assimp_SOURCE_DIR}/contrib/zlib/contrib/minizip/unzip.c
)
endif()

# --- 4. Find System Packages ---
find_package(OpenGL REQUIRED)
# Note: find_package(glm) and find_package(glfw3) are REMOVED because we fetched them above

# --- 4. GLAD Library ---
# --- 5. GLAD Library ---
add_library(GLAD STATIC glad.c)
target_include_directories(GLAD PUBLIC ${CMAKE_SOURCE_DIR}/includes ${CMAKE_SOURCE_DIR}/headers)

# --- 5. Main Executable ---
# --- 6. Main Executable ---
add_executable(opengl_project
main.cpp
src/shader.cpp
src/camera.cpp
src/mesh.cpp
src/model.cpp
src/scene.cpp
src/stb_image.cpp
)

# --- 6. Link Libraries ---
# --- 7. Link Libraries ---
target_link_libraries(opengl_project
PRIVATE
GLAD
glfw
OpenGL::GL
glm::glm
assimp::assimp
)

# 7. Handle the 'dl' library for Linux only
Expand All @@ -71,3 +96,4 @@ target_include_directories(opengl_project PRIVATE
# 9. Copy Assets to Build Directory
file(COPY shaders DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY textures DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY models DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
40 changes: 31 additions & 9 deletions headers/mesh.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
#ifndef MESH_H
#define MESH_H

#pragma once
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <vector>
#include <string>
#include "shader.h"

class Mesh {
public:
unsigned int VAO;
unsigned int VAO, VBO;
unsigned int vertexCount, stride;

// Bestaande constructor (voor kubus/lamp)
Mesh(float* vertices, unsigned int vertexCount, bool hasNormals);
void Draw();
void Delete();

// Assimp modellen
struct Vertex {
glm::vec3 Position;
glm::vec3 Normal;
glm::vec2 TexCoords;
};
struct Texture {
unsigned int id;
std::string type;
// "texture_diffuse" of "texture_normal"
std::string path;
};

// Nieuwe constructor
Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices, std::vector<Texture> textures);
void Draw(Shader& shader); // overload voor model-rendering
void DeleteModel();

private:
unsigned int VBO;
unsigned int vertexCount;
int stride;
// alleen gebruikt door model-constructor
unsigned int EBO;
std::vector<Vertex> _vertices;
std::vector<unsigned int> _indices;
std::vector<Texture> _textures;
void setupModelMesh();
};

#endif
29 changes: 29 additions & 0 deletions headers/model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <stb_image.h>
#include "mesh.h"
#include "shader.h"
#include <vector>
#include <string>
#include <iostream>

class Model {
public:
Model(const std::string& path) { loadModel(path); }
void Draw(Shader& shader);
void Delete();

private:
std::vector<Mesh> meshes;
std::vector<Mesh::Texture> textures_loaded; // cache: niet 2x laden
std::string directory;

void loadModel(const std::string& path);
void processNode(aiNode* node, const aiScene* scene);
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
std::vector<Mesh::Texture> loadMaterialTextures(
aiMaterial* mat, aiTextureType type, const std::string& typeName);
unsigned int textureFromFile(const std::string& filename);
};
22 changes: 18 additions & 4 deletions headers/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <glm/glm.hpp>
#include <shader.h>
#include <mesh.h>
#include <model.h>
#include <vector>
#include <string>
#include <deque>

class Scene {
public:
Expand All @@ -15,17 +19,27 @@ class Scene {
void Delete();

private:
Mesh* cubeMesh;
struct AtomiumPart {
Model* model;
bool isSphere;
std::string filePath;
};
struct DronePart {
Model* model;
std::string filePath;
};

Mesh* lampMesh;
unsigned int texture;

void loadTexture();
void setMaterialUniforms(Shader& shader);
void setLightUniforms(Shader& shader);

unsigned int bezierVAO;
unsigned int bezierVBO;
unsigned int bezierPointCount;

std::vector<AtomiumPart> atomiumParts;
std::vector<DronePart> droneParts;
std::deque<std::string> pendingDronePaths;
};

#endif
Binary file added models/Atomium/Concrete_016_baseColor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added models/Atomium/Concrete_016_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading