lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
model_loader.hpp
Go to the documentation of this file.
1
11
12#pragma once
13
16#include "lmgl/scene/mesh.hpp"
17#include "lmgl/scene/node.hpp"
18
19#include <memory>
20#include <string>
21#include <vector>
22
23struct aiScene;
24struct aiNode;
25struct aiMesh;
26struct aiMaterial;
27
28namespace lmgl {
29
36namespace assets {
37
46 bool flip_uvs = true;
47 bool compute_tangents = true;
48 bool optimize_meshes = true;
49 bool triangulate = true;
50 float scale = 1.0f;
51};
52
61 public:
74 static std::shared_ptr<scene::Node> load(const std::string &fpath, std::shared_ptr<renderer::Shader> shader,
75 const ModelLoadOptions &options);
76
77 private:
90 static std::shared_ptr<scene::Node> process_node(aiNode *ai_node, const aiScene *ai_scene, const std::string &dir,
91 std::shared_ptr<renderer::Shader> shader);
92
105 static std::shared_ptr<scene::Mesh> process_mesh(aiMesh *ai_mesh, const aiScene *ai_scene, const std::string &dir,
106 std::shared_ptr<renderer::Shader> shader);
107
119 static std::vector<std::shared_ptr<renderer::Texture>>
120 load_material_textures(aiMaterial *ai_material, unsigned int type, const std::string &dir);
130 static std::string get_directory(const std::string &filepath);
131
145 static std::shared_ptr<scene::LOD> load_lod(const std::vector<std::string> &file_paths,
146 const std::vector<float> &distances,
147 std::shared_ptr<renderer::Shader> shader,
148 const ModelLoadOptions &options = {});
149};
150
151} // namespace assets
152
153} // namespace lmgl
Class for loading 3D models using Assimp.
Definition model_loader.hpp:60
static std::shared_ptr< scene::Node > load(const std::string &fpath, std::shared_ptr< renderer::Shader > shader, const ModelLoadOptions &options)
Load a 3D model from a file.
Definition model_loader.cpp:16
Defines the Mesh class for managing 3D mesh data.
Namespace for asset loading utilities.
Definition model_loader.cpp:14
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12
Defines the Node class for managing scene graph nodes in a 3D environment.
Declaration of the Shader class for managing shader programs in OpenGL.
Options for loading 3D models.
Definition model_loader.hpp:45
bool triangulate
Whether to triangulate meshes (convert polygons to triangles)
Definition model_loader.hpp:49
float scale
Scale factor to apply to the model.
Definition model_loader.hpp:50
bool optimize_meshes
Whether to optimize meshes for better performance.
Definition model_loader.hpp:48
bool flip_uvs
Whether to flip UV coordinates.
Definition model_loader.hpp:46
bool compute_tangents
Whether to compute tangents for normal mapping.
Definition model_loader.hpp:47
Texture class for managing OpenGL textures.