'Importing 3D models with Assimp not working
I am triing tor read diferent 3D formats using Assimp. My corresponding C++ code looks like this:
void loadScene(string myFile)
{
Importer importer;
const aiScene *scene = importer.ReadFile(myFile, 0);
if(scene) cout<<"OK"<<endl;
else cout<< importer.GetErrorString () <<endl;
}
int main()
{
loadScene("myFile.fbx");
loadScene("myFile.3ds");
loadScene("myFile.obj");
loadScene("myFile.glb");
return 0;
}
and the output:
OBJ: Invalid face indice
OBJ: Invalid face indice
OK
OBJ: Invalid face indice
Can This be fixed? All 4 files, I am triin to read are OK, checked them with some 3D viewer. I checked the reason for that problem is because Assimp always selects the importer for obj format. The simplest solution would be to force Assimp explicitly to use the right importer, since I know exactly which importer is suitable for which file. Unfortunately it seems like Assimp has no way to select importer explicitly.
So what I did, just added this code:
const std::string::size_type s = pFile.find_last_of('.');
if (s != std::string::npos) {
unsigned int a = GetImporterIndex(_pFile+s);
imp = pimpl->mImporter[a];
}
to const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) and my output looks like this:
OK
Chunk is too large
OK
GLTF: Unsupported binary glTF version
The problem with glb file seems to be because wrong importer is used, it should be gltf2 but gltf used instead.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
