Curious (?) problem with loading an asset

Hi all,

I’ve just started developing with jMonkey. I’m using the eclipse platform (I know it is recommended for newbies to use the SDK but I feel really comfortable with eclipse).

In any event, I have been following through the tutorials, got to the “HelloAssets” one.

Everything was working really nicely. When I wanted to use the assets provided by the tutorial, I simply created a folder called “assets” under the HelloJME3 project, then dragged relevant files from the test-data jar. this is what it looks:



HelloJME3

→ src…

→ JRE System Library

→ Referenced Libraries

→ assets

->-> Interface…

->-> Models…

->-> Scenes



Everything was working perfectly, including loading the scene “main.scene” from a zip file.

Then I wanted to use the simple way, and extracted all files under the “town” folder (which include several textures, jpgs etc, as well as a “main.scene” file) into Scenes. So under my main project, HelloJME3, I now have assets/Scenes/town/main.scene.



But this time, jMonkey could not recognize the file! The following code:



Spatial gameLevel = assetManager.loadModel(“Scenes/town/main.scene”);

gave me the following exception:



SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

com.jme3.asset.AssetNotFoundException: Scenes/town/main.scene

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:277)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:368)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:372)

at jme3test.helloworld.HelloAssets.simpleInitApp(HelloAssets.java:56)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)

at java.lang.Thread.run(Unknown Source)



It is worth mentioning that loading OTHER objects, in a similar way, works just fine (for example, the “ninja” etc).

So similar bits of code such as:



guiFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

or

Spatial teapot = assetManager.loadModel(“Models/Teapot/Teapot.obj”);



work very well.

I’ve tried recompiling, re-extracting, changing the file name from main.scene to something else as well as checking the validity of the main.scene file, but I have no clue why this particular line of code doesn’t work.



Any help would be greatly appreciated (moving on for now),



Amir.

If you can drag the files I suppose the jME3-testdata.jar is on the classpath? Then you load from that all the time. Add the assets folder to the classpath too.

1 Like

Actually it was on the classpath, but nothing worked. The file is still in the classpath, although what I did to make the other assets work was open that testdata jar file with winzip, extract the files, then copy them by myself to my eclipse project.



I have renamed the file to jME3-test-data.jar (since that was the name in the tutorial) then added it back through all appropriate places (through libraries in the java build path, using the “external jar” option). I don’t understand how I can add my “assets” folder (which contains images, .scene, .j3o files etc) to the class path which contains java classes, but if that’s what I need to do simply say so and I’ll happily go and figure out how to do it.



I would like to mention again that files from assest/Textures or assets/Models load just fine.



Thanks again!!!



Amir.

Yes, this convinces me more that it is as I said.

1 Like

OK, thank you very much!

Will work on this angle :slight_smile:



Amir.

Alright! It worked.

Just as you said - The files have been previously loaded from the test-data.jar file, not from my own created folder.

Once I created the folder, populated it with anything I wanted (in this case the “town” files), I needed to add it to the classpath

via right click on HelloJME3 → properties → libraries → add external class folder → browse and choose the “assets” folder I created and then we’re done.

I wrote all of this in case someone else in the future encounters the same problems.



Thanks again!! I really didn’t expect such an accurate answer so soon.



Amir.

1 Like