Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void AssimpModel::loadModel(std::string path) {
- Assimp::Importer import;
- const aiScene * scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_GenSmoothNormals |
- aiProcess_CalcTangentSpace | aiProcess_FlipUVs);
- if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
- {
- std::cout << "ERROR::ASSIMP::" << import.GetErrorString() << std::endl;
- return;
- }
- directory = std::filesystem::path(path).parent_path().string();
- processNode(scene->mRootNode, scene, glm::mat4(1.0f));
- }
- void AssimpModel::processNode(aiNode* node, const aiScene* scene, glm::mat4 parent_transformation)
- {
- std::cout << node->mName.C_Str() << std::endl;
- aiMatrix4x4 nodetrans = node->mTransformation;
- nodetrans = nodetrans.Inverse();
- glm::mat4 glmnodetrans = ConvertMatrixToGLMFormat(nodetrans);
- printMat4(parent_transformation);
- glm::mat4 globalTransformation = parent_transformation * glmnodetrans;
- transformarray.push_back(globalTransformation);
- // process all the node's meshes (if any)
- for (unsigned int i = 0; i < node->mNumMeshes; i++)
- {
- aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
- meshes.push_back(processMesh(mesh, scene, globalTransformation));
- }
- // then do the same for each of its children
- for (unsigned int i = 0; i < node->mNumChildren; i++)
- {
- processNode(node->mChildren[i], scene, globalTransformation);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment