The assimp library provides a good way to load .obj 3D models from a file. However, I found out that assimp_viewer.exe, which comes with it (I use version 3.1.1), imports my .obj file (42Mb, already simplified) much faster, and then my C ++ code, which loads the same same model. The viewer downloads the file in a couple of seconds, while my C ++ program (MSVS 2013 / Win64 / Release) takes 154 seconds. I experimented with importer message processing flags both in the viewer and in C ++, but I cannot bridge the gap between them.
Any thoughts on the reason? Here is my C ++ code:
#include <ctime>
#include <iostream>
#include <fstream>
#include <vector>
#include "assimp/Importer.hpp"
#include "assimp/scene.h"
#include "assimp/postprocess.h"
#include "assimp/progresshandler.hpp"
using namespace std;
int main(int argc, char* argv[])
{
Assimp::Importer importer;
unsigned int post_processing_flags = aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices |
aiProcess_OptimizeMeshes | aiProcess_OptimizeGraph | aiProcess_ImproveCacheLocality;
cout << "starting load: ";
auto begin = clock();
auto scene = importer.ReadFile( "MODEL.obj", post_processing_flags);
auto end = clock();
cout << "done!\n";
double seconds = (end - begin) / CLOCKS_PER_SEC;
cout << "loading took " << seconds << " seconds" << endl;
return 0;
}