To load a model file with Open Asset Import Library, we must include the following three headers in the implementation file of the AssimpModel
model loading class in the model
folder:
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
Next, we create an Assimp::Importer
instance in the loadModel()
method, and use the importer to load a file from disk:
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(modelFilename,
aiProcess_Triangulate | aiProcess_GenNormals);
We hand over the file name of the asset file we want to load, plus the two values aiProcess_Triangulate
and aiProcess_GenNormals
as optional postprocessing flags.
The first flag, aiProcess_Triangulate
, instructs Assimp
to triangulate all polygons with more than three vertices, if those polygons exist in the file. Since our basic renderer only understands triangles, a polygon with more than three vertices...