Brenta Engine 1.2
Loading...
Searching...
No Matches
model.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <assimp/Importer.hpp>
9#include <assimp/postprocess.h>
10#include <assimp/scene.h>
11#include <glad/glad.h>
12
13#include <brenta/mesh.hpp>
14#include <brenta/shader.hpp>
15
16#include <string>
17#include <vector>
18#include <memory>
19
20namespace brenta
21{
22
28class model
29{
30public:
31
32 GLint wrapping;
33 GLint filtering_min;
34 GLint filtering_mag;
35 GLboolean has_mipmap;
36 GLint mipmap_min;
37 GLint mipmap_mag;
38 bool flip;
39 std::string path;
40
41 struct config;
42 class builder;
43
44 static const config default_config;
45
52 {
53 }
54
55 model(config conf);
56 ~model();
57
58 constexpr model(const model&) = delete;
59 constexpr model& operator=(const model&) = delete;
60
61 constexpr model(model&&) noexcept = default;
62 constexpr model& operator=(model&&) noexcept = default;;
63
64 void draw(shader::name_t shader) const;
65
66private:
67
68 std::vector<mesh> meshes;
69 std::vector<std::shared_ptr<texture>> textures_loaded;
70 std::string directory;
71
72 void process_node(aiNode *node, const aiScene *scene);
73 void process_mesh(aiMesh *mesh, const aiScene *scene);
74 std::vector<std::shared_ptr<texture>>
75 load_material_textures(aiMaterial *mat,
76 aiTextureType type,
77 const std::string &type_name);
78 void init();
79};
80
82{
83 std::string path;
84 GLint wrapping;
85 GLint filtering_min;
86 GLint filtering_mag;
87 GLboolean has_mipmap;
88 GLint mipmap_min;
89 GLint mipmap_mag;
90 bool flip;
91};
92
97{
98private:
99
100 model::config conf = model::default_config;
101
102public:
103 builder &path(std::string path);
104 builder &wrapping(GLint wrapping);
105 builder &filtering_min(GLint filtering_min);
106 builder &filtering_mag(GLint filtering_mag);
107 builder &has_mipmap(GLboolean has_mipmap);
108 builder &mipmap_min(GLint mipmap_min);
109 builder &mipmap_mag(GLint mipmap_mag);
110 builder &flip(bool flip);
111
112 model build();
113};
114
115} // namespace brenta
The Mesh class represents a 3D model.
Definition mesh.hpp:51
Builder class for Model.
Definition model.hpp:97
Model class.
Definition model.hpp:29
model()
Empty constructor.
Definition model.hpp:51
Shader class.
Definition shader.hpp:36
Texture class.
Definition texture.hpp:20