0

I am using JMonkeyEngine with Eclipse and I'm having trouble loading a model.

@Override
    public void simpleInitApp() {    
        Spatial monkey = assetManager.loadModel("Monkey.obj"); //<---line 34
        Material mat_default = new Material( 
            assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
        monkey.setMaterial(mat_default);
        rootNode.attachChild(monkey);    
    }

I originally had the file in the "assets" folder, however after some research I discovered that assetManager has access to the main project directory and I thought that maybe it cannot access the assets folder so instead I temporarily moved the Monkey.obj to the main directory.

The error I'm getting looks like this:

Jan 09, 2015 1:10:14 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.0 RC2
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Lwjgl 2.9.0 context running on thread LWJGL Renderer Thread
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: nvd3dumx,nvwgf2umx,nvwgf2umx
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: 9.18.13.4709
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: NVIDIA Corporation
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 4.5.0 NVIDIA 347.09
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: GeForce GTX 770/PCIe/SSE2
Jan 09, 2015 1:10:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.50 NVIDIA
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Device: OpenAL Soft
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Vendor: OpenAL Community
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Renderer: OpenAL Soft
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Version: 1.1 ALSOFT 1.15.1
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
Jan 09, 2015 1:10:14 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
Jan 09, 2015 1:10:14 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.asset.AssetNotFoundException: Monkey.obj
    at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:283)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:374)
    at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:378)
    at MainGame.Main.simpleInitApp(Main.java:34)
    at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
    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)

Am I using the assetManager correctly?

MagnusCaligo
  • 707
  • 2
  • 8
  • 28

1 Answers1

0

I had a look at the line where the exception is thrown in the JME source and it is definitely trying to locate your resource at that point and can't find it. It's pretty difficult to diagnose why the loader is not finding your model. I will say that in my project my models are in "assets/Models/" and I load them using:

getAssetManager().loadModel("Models/items.blend");

So I do think they need to be under the "assets" directory.

Other than that the only suggestion I have is to find some standard models on the net and try storing them in "assets" and loading them to make sure there's not a problem with reading directories or permissions.

sprinter
  • 27,148
  • 6
  • 47
  • 78
  • So I created a Models folder inside the assets folder and moved the .obj to that folder and tried your method however that still didn't work. I even tried it with a different obj (because I actually discovered the obj I was using was broken). Just out of curiosity, are you working in the JMonkeyEngine SDK or in another IDE? Also I saw that you loaded a .blend file, can JME load .blend files just like .obj files because that would be really helpful! – MagnusCaligo Jan 10 '15 at 13:15
  • @MagnusCaligo no I'm not using the JME SDK. I wanted to use Java 8 with my project which isn't currently supported. I use NetBeans 8.0. Yes JME can load blender files (with some restrictions - check the doco). Unfortunately it's hard to know what your problem is. I assume you've followed the advice in http://hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:asset_manager ? Can you confirm you've done the steps under 'cannot locate resource?' – sprinter Jan 10 '15 at 22:49
  • I followed your link and it had me convert the .obj to a .j3o, however that still didn't work. The next thing i'm going to try is test the program in the SDK to see if it works there. – MagnusCaligo Jan 11 '15 at 05:17
  • is the audio working? did you try turning it off? i notice you have `INFO: Audio max auxilary sends: 4` which is what im getting when trying to play an audio file and its not working. – jsky Oct 10 '15 at 12:08