| 73 | } |
| 74 | |
| 75 | bool Model::LoadFromFile(const std::string& path) |
| 76 | { |
| 77 | ed::Logger::Get().Log("Loading a 3D model from file \"" + path + "\""); |
| 78 | |
| 79 | // read file via ASSIMP |
| 80 | Assimp::Importer importer; |
| 81 | const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs); |
| 82 | |
| 83 | // check for errors |
| 84 | if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero |
| 85 | { |
| 86 | ed::Logger::Get().Log("Assimp has detected an error \"" + std::string(importer.GetErrorString()) + "\"", true); |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | Directory = path.substr(0, path.find_last_of("/\\")); |
| 91 | m_processNode(scene->mRootNode, scene); |
| 92 | |
| 93 | m_findBounds(); |
| 94 | |
| 95 | return true; |
| 96 | } |
| 97 | void Model::m_findBounds() |
| 98 | { |
| 99 | m_minBound = glm::vec3(std::numeric_limits<float>::infinity()); |
no test coverage detected