2021-12-07 19:51:12 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-22 02:52:06 +00:00
|
|
|
#include "mesh.h"
|
|
|
|
#include "simpleengine/gfx/texture.h"
|
2021-12-07 19:51:12 +00:00
|
|
|
|
2022-09-22 02:52:06 +00:00
|
|
|
#include <assimp/material.h>
|
|
|
|
#include <assimp/mesh.h>
|
|
|
|
#include <assimp/scene.h>
|
|
|
|
|
|
|
|
//#include <assimp/mesh.h>
|
2021-12-07 19:51:12 +00:00
|
|
|
|
|
|
|
namespace simpleengine::gfx {
|
2022-09-27 04:26:50 +00:00
|
|
|
enum ModelProcessingFlags : uint8_t {
|
|
|
|
MdlProcFlag_NONE = 0b00000000,
|
|
|
|
MdlProcFlag_FLIP_TEX_COORDS_VERTICALLY = 0b00000001,
|
|
|
|
MdlProcFlag_FLIP_TEX_COORDS_HORIZONTALLY = 0b00000010,
|
|
|
|
};
|
|
|
|
|
2022-08-19 04:20:53 +00:00
|
|
|
/**
|
2022-09-22 02:52:06 +00:00
|
|
|
* @brief A Model is a group of Meshes read from the 3D model file.
|
|
|
|
*
|
|
|
|
* The engine uses assimp, so all formats that it supports can be found here:
|
|
|
|
* https://github.com/assimp/assimp/blob/master/doc/Fileformats.md
|
2022-08-19 04:20:53 +00:00
|
|
|
*
|
|
|
|
*/
|
2022-09-22 02:52:06 +00:00
|
|
|
class Model : public simpleengine::Transformable {
|
|
|
|
protected:
|
|
|
|
std::string model_directory; // May be needed
|
2022-09-27 04:26:50 +00:00
|
|
|
int additional_assimp_flags;
|
|
|
|
int model_processing_flags;
|
2021-12-07 19:51:12 +00:00
|
|
|
public:
|
2022-09-22 02:52:06 +00:00
|
|
|
std::vector<gfx::Mesh> meshes;
|
|
|
|
|
2022-09-27 04:26:50 +00:00
|
|
|
Model(std::string file_path, int model_processing_flags = ModelProcessingFlags::MdlProcFlag_NONE, int assimp_flags = 0);
|
2022-09-22 02:52:06 +00:00
|
|
|
|
|
|
|
void load_model(std::string path);
|
2022-09-27 03:43:08 +00:00
|
|
|
void process_node(std::unordered_map<aiTextureType, std::vector<std::shared_ptr<Texture>>>& processed_textures, aiNode* node, const aiScene* scene);
|
|
|
|
gfx::Mesh process_mesh(std::unordered_map<aiTextureType, std::vector<std::shared_ptr<Texture>>>& processed_textures, aiMesh* mesh, const aiScene* scene);
|
|
|
|
|
|
|
|
std::unordered_map<aiTextureType, std::vector<Texture>> load_all_textures(aiMaterial* material);
|
2022-09-29 01:21:47 +00:00
|
|
|
std::vector<std::shared_ptr<Texture>> load_material_texture(std::unordered_map<aiTextureType, std::vector<std::shared_ptr<Texture>>>& processed_textures, aiMaterial* material, aiTextureType type, TextureFlags texture_color);
|
2022-09-27 04:26:50 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void post_process();
|
|
|
|
public:
|
|
|
|
|
|
|
|
void vertically_flip_tex_coords();
|
|
|
|
void horizontally_flip_tex_coords();
|
2021-12-07 19:51:12 +00:00
|
|
|
};
|
|
|
|
}
|