3.1.2 Mesh::loadModel()
For full code, please move directly to the end of this page
Use Assimp to load models
In Mesh.cpp, write your loadModel function.
We are not using the hierarchical scene graph of Assimp at the moment, we only read the meshes in the Scene node.
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path, aiProcess_CalcTangentSpace);
if (NULL != scene) {
std::cout << "load model successful" << std::endl;
} else {
std::cout << "load model failed" << std::endl;
}
// mNumMeshes should > 0
//std::cout << scene->mNumMeshes << std::endl;Assimp Scene graph

Read vertex and triangle data
We are going to read Assimp mesh data to our buffer in a loop
First read vertex position and normals (we don't deal with texture at the moment)
Then read triangle indices
Full Source Code
Last updated