We first declare an Importer object from Assimp's namespace and then call its ReadFile function. The great thing about Assimp is that it neatly abstracts from all the technical details of loading all the different file formats and does all this with a single one-liner:Ĭonst aiScene *scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs) Once we have the scene object, we can access all the data we need from the loaded model. You may remember from the first chapter of the model loading series that this is the root object of Assimp's data interface. Within loadModel, we use Assimp to load the model into a data structure of Assimp called a scene object. The first function we're calling is loadModel, that's directly called from the constructor. The Draw function is nothing special and basically loops over each of the meshes to call their respective Draw function: We also store the directory of the file path that we'll later need when loading textures. The private functions are all designed to process a part of Assimp's import routine and we'll cover them shortly. It then loads the file right away via the loadModel function that is called in the constructor. The Model class contains a vector of Mesh objects and requires us to give it a file location in its constructor. Vector loadMaterialTextures(aiMaterial *mat, aiTextureType type, Mesh processMesh(aiMesh *mesh, const aiScene *scene) Void processNode(aiNode *node, const aiScene *scene) Without further ado, I present you the class structure of the Model class: We'll load the model via Assimp and translate it to multiple Mesh objects we've created in the previous chapter. A house, that contains a wooden balcony, a tower, and perhaps a swimming pool, could still be loaded as a single model. The goal of this chapter is to create another class that represents a model in its entirety, that is, a model that contains multiple meshes, possibly with multiple textures. Now it is time to get our hands dirty with Assimp and start creating the actual loading and translation code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |