restructure v2

This commit is contained in:
Claire Schwarzer 2026-07-08 14:24:34 +02:00
parent e01595e155
commit dc5654ba9a
20 changed files with 910 additions and 791 deletions

39
engine/Backend/Model.h Normal file
View file

@ -0,0 +1,39 @@
#pragma once
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <engine/Backend/Shader.h>
#include <engine/Backend/Mesh.h>
class Model
{
public:
// model data
vector<Texture> textures_loaded; // stores all the textures loaded so far, optimization to make sure textures aren't loaded more than once.
vector<Mesh> meshes;
string directory;
bool gammaCorrection;
// constructor, expects a filepath to a 3D model.
Model(string const &path, bool gamma = false);
// draws the model, and thus all its meshes
void Draw(Shader &shader);
private:
// loads a model with supported ASSIMP extensions from file and stores the resulting meshes in the meshes vector.
void loadModel(string const &path);
// processes a node in a recursive fashion. Processes each individual mesh located at the node and repeats this process on its children nodes (if any).
void processNode(aiNode *node, const aiScene *scene);
Mesh processMesh(aiMesh *mesh, const aiScene *scene);
// checks all material textures of a given type and loads the textures if they're not loaded yet.
// the required info is returned as a Texture struct.
vector<Texture> loadMaterialTextures(aiMaterial *mat, aiTextureType type, string typeName, bool fallback = false);
};
unsigned inline int TextureFromFile(const char *path, const string &directory, bool gamma = false);