more work on asset registry and importing process
This commit is contained in:
@@ -15,15 +15,14 @@
|
||||
#include "TextureManager.h"
|
||||
#include "glm/ext/matrix_transform.hpp"
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<Model>> ModelManager::models;
|
||||
std::unordered_map<uuids::uuid, std::unique_ptr<Model>> ModelManager::models;
|
||||
|
||||
void process_ai_node(aiNode* node, const aiScene* scene, glm::mat4 transform, ModelNode& model);
|
||||
|
||||
void process_ai_mesh(const aiMesh* aiMesh, Mesh& mesh);
|
||||
|
||||
void process_ai_material(const aiMaterial* aiMat, Material& mat, const std::filesystem::path& modelDirectory);
|
||||
/*void process_ai_material(const aiMaterial* aiMat, Material& mat, const std::filesystem::path& modelDirectory);
|
||||
void process_ai_material_diffuse(const aiMaterial *aiMat, Material& mat, const std::filesystem::path& modelDirectory);
|
||||
void process_ai_material_specular(const aiMaterial *aiMat, Material& mat, const std::filesystem::path& modelDirectory);
|
||||
void process_ai_material_specular(const aiMaterial *aiMat, Material& mat, const std::filesystem::path& modelDirectory);*/
|
||||
|
||||
auto zUpMatrix = glm::mat4(
|
||||
1.0f, 0.0f, 0.0f, 0.0f, // Column 0
|
||||
@@ -32,7 +31,7 @@ auto zUpMatrix = glm::mat4(
|
||||
0.0f, 0.0f, 0.0f, 1.0f // Column 3
|
||||
);
|
||||
|
||||
std::shared_ptr<Model> ModelManager::load_from_file(std::string_view _path, bool zUp)
|
||||
std::unique_ptr<Model> ModelManager::load_from_file(std::string_view _path, bool zUp)
|
||||
{
|
||||
Assimp::Importer importer;
|
||||
|
||||
@@ -47,10 +46,10 @@ std::shared_ptr<Model> ModelManager::load_from_file(std::string_view _path, bool
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto model = std::make_shared<Model>();
|
||||
auto model = std::make_unique<Model>();
|
||||
|
||||
const std::filesystem::path modelPath = {_path};
|
||||
for (unsigned int i = 0; i < scene->mNumMaterials; i++) {
|
||||
/*for (unsigned int i = 0; i < scene->mNumMaterials; i++) {
|
||||
aiMaterial* aiMat = scene->mMaterials[i];
|
||||
aiString matName;
|
||||
if (aiMat->Get(AI_MATKEY_NAME, matName) && strcmp(matName.data, "DefaultMaterial") == 0) {
|
||||
@@ -59,7 +58,7 @@ std::shared_ptr<Model> ModelManager::load_from_file(std::string_view _path, bool
|
||||
Material mat{};
|
||||
process_ai_material(aiMat, mat, modelPath.parent_path());
|
||||
model->materials.push_back(std::make_shared<Material>(mat));
|
||||
}
|
||||
}*/
|
||||
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes; i++) {
|
||||
aiMesh* aiMesh = scene->mMeshes[i];
|
||||
@@ -148,7 +147,7 @@ void process_ai_mesh(const aiMesh* aiMesh, Mesh& mesh)
|
||||
mesh = {positions, uvs, normals, indices};
|
||||
}
|
||||
|
||||
void process_ai_material(const aiMaterial* aiMat, Material& mat, const std::filesystem::path& modelDirectory) {
|
||||
/*void process_ai_material(const aiMaterial* aiMat, Material& mat, const std::filesystem::path& modelDirectory) {
|
||||
aiString matName;
|
||||
aiReturn ret = aiMat->Get(AI_MATKEY_NAME, matName);
|
||||
if (ret != AI_SUCCESS) {
|
||||
@@ -193,9 +192,9 @@ void process_ai_material(const aiMaterial* aiMat, Material& mat, const std::file
|
||||
mat.phong.diffuse = glm::vec3{diffuseColor.r, diffuseColor.g, diffuseColor.b};
|
||||
mat.phong.specular = glm::vec3{specularColor.r, specularColor.g, specularColor.b};
|
||||
mat.phong.shininess = shininess;
|
||||
}
|
||||
}*/
|
||||
|
||||
void process_ai_material_diffuse(const aiMaterial *aiMat, Material& mat, const std::filesystem::path& modelDirectory) {
|
||||
/*void process_ai_material_diffuse(const aiMaterial *aiMat, Material& mat, const std::filesystem::path& modelDirectory) {
|
||||
aiString aiTextureName;
|
||||
aiMat->GetTexture(aiTextureType_DIFFUSE, 0, &aiTextureName);
|
||||
std::string textureName = aiTextureName.C_Str();
|
||||
@@ -259,4 +258,4 @@ void process_ai_material_specular(const aiMaterial *aiMat, Material& mat, const
|
||||
} else {
|
||||
mat.specular = TextureManager::textures["default_specular"];
|
||||
}
|
||||
}
|
||||
}*/
|
||||
Reference in New Issue
Block a user