Skip to content

Conversation

@tlf30
Copy link
Contributor

@tlf30 tlf30 commented Dec 9, 2020

This is a fix for when the gltf exporter creates an empty scene node from blender. For example:

    "scenes" : [
        {
            "name" : "KB3D_NeoShanghai-Native",
            "nodes" : [
                5
            ]
        },
        {
            "name" : "Scene"
        }
    ],

This will make the exporter skip attempting to read the nodes from the empty scene, as there are no nodes in the scene.

@pspeed42
Copy link
Contributor

pspeed42 commented Dec 9, 2020

What happens without this code?

@tlf30
Copy link
Contributor Author

tlf30 commented Dec 9, 2020

What happens without this code?

The following error will cause the application to crash:

com.jme3.asset.AssetLoadException: An error occurred loading Models/KB3D_NeoShanghai-Native_BldgSM_H.gltf
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:182)
	at com.jme3.scene.plugins.gltf.GltfLoader.load(GltfLoader.java:110)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:260)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:374)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:417)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:421)
	at io.tlf.jme.test.Main.simpleInitApp(Main.java:36)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:239)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:520)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:632)
	at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:473)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:463)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:127)
	at io.tlf.jme.test.Main.main(Main.java:145)
Caused by: java.lang.NullPointerException
	at com.jme3.scene.plugins.gltf.GltfLoader.readScenes(GltfLoader.java:214)
	at com.jme3.scene.plugins.gltf.GltfLoader.loadFromStream(GltfLoader.java:159)
	... 14 more

Caused by: java.lang.NullPointerException

@stephengold
Copy link
Member

  1. Please add a test case for the issue.
  2. The comment is grammatically incorrect. I suggest:
// If the scene is empty, ignore it.

@tlf30
Copy link
Contributor Author

tlf30 commented Dec 11, 2020

@stephengold how does this test look?
I ran it with the added code for the fix removed, and it failed. Added the fix back in and it passed.
Not entirely sure how you wanted the test, as there are inconstancies between the different jme subprojects. I just added this one along side the existing gltf test. If it needs to be elsewhere, or structured differently, please let me know.

@stephengold
Copy link
Member

That looks great. Thank you for your contribution to the project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants