Spatial model = assetManager.loadModel(“Models/gltf/rocket/scene.gltf”);
but it fails with
com.jme3.asset.AssetLoadException: An error occurred loading Models/gltf/rocket/scene.gltf
at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:181)
at com.jme3.scene.plugins.gltf.GltfLoader.load(GltfLoader.java:106)
at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:439)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:444)
at com.joejoe2.glass.HelloJME.simpleInitApp(HelloJME.java:64)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
at com.joejoe2.glass.MyAndroidHarnessFragment.initialize(MyAndroidHarnessFragment.java:529)
at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:342)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1591)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1286)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘com.jme3.scene.Node com.jme3.scene.Spatial.getParent()’ on a null object reference
at com.jme3.anim.SkinningControl.getAttachmentsNode(SkinningControl.java:403)
at com.jme3.scene.plugins.gltf.GltfLoader.setupControls(GltfLoader.java:1151)
at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:166)
I also found that an glb model size=16mb will throw the out of memory error on my device (Android). Is there any method to increase the heap size or reduce the quality wile loading ? because I can load it on SceneForm library, but i do not know how it works
You shouldn’t be loading a glTF model on a device with small memory. Instead, you should convert the model to J3O format (on a build system with plenty of memory), install the J3O on the target device, and load that instead.
Another question, I wonder that if i have multiple material with this gltf, how can i decide the loader to load specific materail ? And the lights defined in gltf/glb seems to not work, i have to set directional light everytime.
Do you appreciate the effort I put into trying to help you? If so, it would be courteous to say “thank you” or to click on the heart-shaped icon under my post.