modelmaxwidthminassimp

how to get the model's max x,y,z withing loading model by assimp


I want to split model space with octree to check intersection detection, so i need known model's max x,y,z and min xyz.

to get the result,i traverse all meshes's vertex and compare them


Solution

  • There is a post-processing step for that. You can use it in the following way:

    #include <assimp/Importer.hpp>
    
    ::Assimp::Importer importer;
    auto scene = importer.import("testmodel.obj", aiProcess_GenBoundingBoxes);
    const aabb &aabb = scene->mMeshes[0]->mAABB;
    

    At first you have to enable the flag when you are starting the import. Then the post-processing will iterate through all imported meshes and fill the bounding boxes.

    And here is a simple unittest for the feature: Bounding boxes unittest