Assimp is a great library for loading OpenGL models. At the moment I'm using SketchUp to create some 3D models and I export them using the "OBJ" format. Assimp can load this "OBJ" format but does not join all the meshes into one.
If you are using the internet sample "Importing 3D Models with Assimp" you see that the drawing in OpenGL loops over all the meshes. Every drawcall is a roundtrip from the CPU to the GPU and back, so you want to prevent that. So you want to merge all meshes into one.
This is possible in assimp using the flag aiProcess_OptimizeGraph. Some code:
scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality | aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes);
Not quite. These options certainly reduce the number of meshes, but it doesn't always fold everything down into one mesh (The 'spider.obj' model in the test assets of AssImp source code will only fold down into 4 meshes - I haven't worked out how to get this down to 1 yet.
BeantwoordenVerwijderenThis will be one mesh per material. Old OpenGL could only have one active texture.
BeantwoordenVerwijderenNowadays, I load the mesh with my own .obj loader and merge everything to one mesh. I use a spritesheetpacker to pack all the textures into one texture. So, the whole scene is drawn in one drawcall.