GLTF/GLB import bug

I downloaded latest version of Urho from git and couldn’t import gltf/glb file with AssetImporter. It basically complains that file extension is not supported. I opened assimp code and this is gltf2.0 importer(this function check if given importer can read file):

bool glTF2Importer::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
{
    const std::string &extension = GetExtension(pFile);

    if (extension != "gltf" && extension != "glb")
        return false;

    if (checkSig && pIOHandler) {
        glTF2::Asset asset(pIOHandler);
        try {
            asset.Load(pFile, extension == "glb");
            std::string version = asset.asset.version;
            return !version.empty() && version[0] == '2';
        } catch (...) {
            return false;
        }
    }

    return false;
}

I guess it’s a bug, it doesn’t return true if extension match, i basically added

    else {
        return true;
    }

after if (checkSig && pIOHandler) { block and now it can import gltf(tho no material imported correctly, but i guess it’s always the case?)

Looks like it’s old version that doesn’t support animations either. Does anybody has fixes for gltf import?

I personally consider AssImp as dead end “equally bad for everything”-kind of solution.
I just import GLTF directly via tinygltf and convert it to Model/Scene. It’s not an easy task, but it’s very doable. And, unlike Assimp, I can actually fix problems when I encounter them.

image

I have a more recent Assimp library in below branch
I up-merged it 2 years ago due to some GLTF issues (don’t remember which) ,
Check if it solves your issues.
I might upmerge to the latest version in the near future once I will have some free time (just follow my master branch)

2 Likes

Can you share code of how you convert it with tinygltf?

My work is far from finished, so I don’t have persistent link.
Here is temporary link to the main file of the importer and to the model builder. This link will perish after I complete this task.

Update: here are permanent links
rbfx/GLTFImporter.cpp at master · rbfx/rbfx · GitHub
rbfx/ModelView.cpp at master · rbfx/rbfx · GitHub

3 Likes