Guest User

Untitled

a guest
Nov 21st, 2025
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. void AssimpModel::loadModel(std::string path) {
  2. Assimp::Importer import;
  3. const aiScene * scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_GenSmoothNormals |
  4. aiProcess_CalcTangentSpace | aiProcess_FlipUVs);
  5. if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
  6. {
  7. std::cout << "ERROR::ASSIMP::" << import.GetErrorString() << std::endl;
  8. return;
  9. }
  10. directory = std::filesystem::path(path).parent_path().string();
  11. processNode(scene->mRootNode, scene, glm::mat4(1.0f));
  12. }
  13.  
  14. void AssimpModel::processNode(aiNode* node, const aiScene* scene, glm::mat4 parent_transformation)
  15. {
  16. std::cout << node->mName.C_Str() << std::endl;
  17. aiMatrix4x4 nodetrans = node->mTransformation;
  18. nodetrans = nodetrans.Inverse();
  19. glm::mat4 glmnodetrans = ConvertMatrixToGLMFormat(nodetrans);
  20. printMat4(parent_transformation);
  21. glm::mat4 globalTransformation = parent_transformation * glmnodetrans;
  22. transformarray.push_back(globalTransformation);
  23. // process all the node's meshes (if any)
  24. for (unsigned int i = 0; i < node->mNumMeshes; i++)
  25. {
  26. aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
  27. meshes.push_back(processMesh(mesh, scene, globalTransformation));
  28. }
  29. // then do the same for each of its children
  30. for (unsigned int i = 0; i < node->mNumChildren; i++)
  31. {
  32. processNode(node->mChildren[i], scene, globalTransformation);
  33. }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment