stephengold / MonkeyWrench

A versatile library for loading 3-D assets into JMonkeyEngine (code has New BSD license)
Other
12 stars 0 forks source link

glTFs with an AnimComposer but no skeleton throw an exception #2

Open stephengold opened 5 months ago

stephengold commented 5 months ago

Reported by @capdevon at the JME forum:

https://hub.jmonkeyengine.org/t/assimp-based-model-import-and-the-monkeywrench-library/46930/66

A copy of the stack trace:

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.asset.AssetLoadException: An exception has occurred while loading asset: Models/Zombiegirl/Running.gltf
    at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:274)
    at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:439)
    at com.capdevon.test.Test_AssetManager.simpleInitApp(Test_AssetManager.java:69)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
    at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:607)
    at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:710)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: Assimp failed to import an asset from "Models/Zombiegirl/Running.gltf":
 No materials remaining
    at com.github.stephengold.wrench.LwjglAssetLoader.loadScene(LwjglAssetLoader.java:144)
    at com.github.stephengold.wrench.LwjglAssetLoader.load(LwjglAssetLoader.java:95)
    at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
    ... 7 more
stephengold commented 5 months ago

This appears to be a direct result of https://github.com/assimp/assimp/issues/5438 . A fix has been submitted: https://github.com/assimp/assimp/pull/5439 . I'll leave this issue open until a fix makes its way into a stable build of LWJGL---I estimate 6-to-12 months.

In the mean time, the best workaround is to disable RemoveRedundantMaterials post processing:

    int ppFlags = Assimp.aiProcess_CalcTangentSpace
            | Assimp.aiProcess_JoinIdenticalVertices
            | Assimp.aiProcess_Triangulate
            | Assimp.aiProcess_ValidateDataStructure
            | Assimp.aiProcess_SortByPType;
    LwjglAssetKey key = new LwjglAssetKey("Models/Zombiegirl/Running.gltf", ppFlags);
    Spatial m = assetManager.loadModel(key);
stephengold commented 3 months ago

On 1 February, Kim wrote and integrated his own solution (PR 5451) for the issue. 5451 introduced a new bug (issue 5461), for which I submitted PR 5467. 5467 has now been integrated into assimp's master branch.