[BUG][WORK-AROUND] AssetNotFoundException when SDK sees it

I get an AssetNotFoundException loading a .j3o file made from a Blender colored cube. The converted file is copied into the assets/Models folder; [RMB] View Model on the .glTF works, and [RMB} Edit in SceneComposer works on the ,j3o. But the loadmodel() call fails. It could be a related file, but the .bin is present. Here is a view from the IDE:

Here are my steps to create the cube and to place it into the application:
Start Blender v2.93.4
Choose New File > General
Delete Cube, Light, and Camera
Add 6 planes; translate and rotate to make a cube
ZPosBlue, ZNegYellow, YPosGreen, YNegMagenta, XPosRed, XNegCyan
{Make sure normals are pointing outward}
{TAB to enter Edit Mode, Face Select, Display Overlays, Display Face Normals (Size 1)}
{Alt-N, Flip or select Face and rotate on axis}
Save As… > ColoredCube.blend
Export > glTF 2.0 > glTF Separate (.gltf + .bin + .textures)
> Include > {nothing checked}
> Transform > +Y Up checked {by default}
Exported: ColoredCube.gltf, ColoredCube.bin
Note: Windows Explorer File Preview of ColoredCube.gltf shows a spinning gray cube

Start JME3 SDK v3.3
File > New Project… > JME3 > Basic Gradle Game - jme3-asset-test
JME3 Projects tab has jme3-asset-test and jme3-asset-test:assets
Copy ColoredCube{.gltf,.bin} to {my-projects}\jme3-asset-test\assets\Models
jme3-asset-test > Project Assets > Models has the files
jme3-asset-test > Build Scripts > build.gradle > change jmeVer = ‘3.4.0-stable’
jme3-asset-test > Build Scripts > settings.gradle > change rootProject.name = ‘jme-asset-test’
Clean and Build Project - BUILD SUCCESSFUL, no warnings
jme3-asset-test > Project Assets > Models > ColoredCube.gltf > right-click > View Model
black cube shown on all sides when drag-rotated
Click Lightbulb
Colored cube shown on all sides when drag-rotated
Wireframe shows two triangles per face
Note: Toggle the Skybox matching the PBR: Exception Textures/SkyPath.hdr (Flipped)
jme3-asset-test > Project Assets > Models > ColoredCube.gltf > right-click > Convert to j3o Binary
ColoredCube.j3o built in jme3-asset-test > Project Assets > Models
right-click > Edit in SceneExplorer
black cube shown on all sides when drag-rotated
Click Lightbulb
Colored cube shown on all sides when drag-rotated
+X=XPosRed, -X=XNegCyan, +Y=ZPosBlue, -Y=ZNegYellow, +Z=YNegMagenta, -Z=YPosGreen
Note: I expected Y going to Z, but didn’t expect Z going to Y in reverse
Clean and Build Project - BUILD SUCCESSFUL, no warnings
Run Project
Note: Illegal reflective access by com.jme3.util.ReflectionAllocator
({user}/.gradle/caches/modules-2/files-2.1/org.jmonkeyengine/jme3-core/3.4.0-stable/b9ba72eb70d09a73c726e17e172652981ae7f9ed/jme3-core-3.4.0-stable.jar) to method sun.nio.ch.DirectBuffer.cleaner()
Blue cube of Basic Gradle Game displayed
End program
jme-asset-test > Source Packages > com.mygame > Main.java
Add at the end of simpleInitApp():
Spatial cube = assetManager.loadModel(“Models/ColoredCube.j3o”);
Note: IDE detects and completes “Models/ColoredCube.j3o” path string
rootNode.attachChild(cube);
Clean and Build Project - BUILD SUCCESSFUL, no warnings
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
com.jme3.asset.AssetNotFoundException: Models/ColoredCube.j3o
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:385)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:439)
at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:444)
at com.mygame.Main.simpleInitApp(Main.java:34)

I wonder if this is the same problem other folks are seeing with the gradle template in the SDK.

[WORK-AROUND] Oh! I added assetManager.registerLocator("assets/", FileLocator.class); and the application ran without an error.

But I saw a blue cube intermittently being drawn with diagonals of blue. :thinking: So, I removed the default blue cube (being overwritten), and the view was completely black. :thinking: So, I added a shadow filter for a sun and everything was still black. :roll_eyes: So, I added a sun to make the shadows. And I saw three faces of my cube! Then, I added a spotlight at (-4f,-4f,-4f) pointing to (1f,1f,1f), and I saw all the faces!

The +Z=YNegMagenta was front and center. Rotating counter-clockwise, I saw -X=XNegCyan, then -Z=YPosGreen, then +X=XPosRed, with +Y=ZPosBlue on top, and -Y=ZNegYellow on the bottom.

(And I would Alt-Tab between the view and browser and editor, cutting+pasting text, and lose the cube in the view - because using the mouse to select text in other programs still had the mouse active in the view and it was rotating my camera away from the cube :smiley: )

Yeah, but you shouldn’t have to do that because the classpath should already have the assets in it. But something is messed up with the template.

…in the end this will cause you issues when you try to bundle the application, I guess. Until then it is an ok work-around.

Yep, this is a bug in the SDK. https://github.com/jMonkeyEngine/sdk/issues/301. For tracking.

2 Likes

What?! I don’t get a Forum “Earned ‘Bug Breeder’” badge? :smiley:

1 Like

I bet fixing the bug would earn pretty cool badge… :wink:

Baby steps … But I’ll get there.

1 Like