-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextured_model_loading.hpp
More file actions
61 lines (49 loc) · 2.26 KB
/
textured_model_loading.hpp
File metadata and controls
61 lines (49 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef TEXTURED_MODEL_LOADING_HPP
#define TEXTURED_MODEL_LOADING_HPP
#include "glm/glm.hpp"
#include <string>
#include <utility>
#include <vector>
/*#include <GLFW/glfw3.h>*/
#include <assimp/scene.h>
#include "sbpt_generated_includes.hpp"
enum TextureType { DIFFUSE, SPECULAR };
struct TextureInfo {
TextureType type;
std::string path;
};
class TexturedMesh : public Mesh {
public:
TexturedMesh(std::vector<glm::vec3> vertex_positions, std::vector<unsigned int> indices,
std::vector<glm::vec2> texture_coordinates, std::vector<glm::vec3> normals,
std::vector<TextureInfo> &used_textures)
: Mesh(vertex_positions, indices), texture_coordinates(texture_coordinates), normals(normals),
used_textures(used_textures) {
assert(normals.size() == texture_coordinates.size() && texture_coordinates.size() == vertex_positions.size());
};
std::vector<TextureInfo> used_textures;
std::vector<glm::vec2> texture_coordinates;
std::vector<glm::vec3> normals;
unsigned int vertex_attribute_object{}, vertex_buffer_object{}, element_buffer_object{};
};
class TexturedModel {
public:
TexturedModel(std::vector<TexturedMesh> meshes) : meshes(meshes) {};
std::vector<TexturedMesh> meshes;
std::vector<std::vector<glm::vec3>> get_ordered_vertex_positions_for_each_mesh();
};
class TexturedModelLoader : ModelLoader {
// void recursively_process_nodes(aiNode *node, const aiScene *scene);
// std::vector<Vertex> process_mesh_vertices(aiMesh *mesh);
// std::vector<unsigned int> process_mesh_indices(aiMesh *mesh);
std::pair<std::vector<glm::vec2>, std::vector<glm::vec3>> process_mesh_vertices_texture_info(aiMesh *mesh);
std::vector<TextureInfo> process_mesh_materials(aiMesh *mesh, const aiScene *scene);
std::vector<TextureInfo> get_texture_info_for_material(aiMaterial *material, aiTextureType type,
TextureType texture_type);
TexturedMesh process_mesh(aiMesh *mesh, const aiScene *scene);
void process_function(aiMesh *mesh, const aiScene *scene);
std::vector<TexturedMesh> recursively_collected_meshes;
public:
TexturedModel load_model(const std::string &path);
};
#endif // TEXTURED_MODEL_LOADING_HPP