Problem loading model using Eclipse

Hi,



First: thanks for the fantastic work on JME3.



I’m trying to run the HelloAssets tutorial example from Eclipse. I have cut it down so that it only attempts to load the teapot model, which I converted to .j3o binary format in the SDK. (The SDK version works without hassles; I’m trying to grasp how to load models without the help of the SDK scripts.)



The model, “teapot.j3o”, is in a “models” folder which is in the android “assets” folder.



I have the following jars on the build path, all from the latest nightly:

jME3-android.jar

jME3-core.jar

jME3-desktop.jar (not sure if this is needed)

jME3-plugins.jar



I get the following output from logcat:

02-01 13:39:04.337: E/AndroidHarness(24377): com.jme3.asset.AssetLoadException: Error occured while loading asset “models/teapot.j3o” usingBinaryImporter

02-01 13:39:04.337: E/AndroidHarness(24377): SEVERE AndroidHarness 1:39:04 PM Exception thrown in Thread[GLThread 17,5,main]: at com.jme3.asset.DesktopAssetManager.loadAsset(280)

02-01 13:39:04.337: E/AndroidHarness(24377): at com.jme3.asset.DesktopAssetManager.loadModel(408)

02-01 13:39:04.337: E/AndroidHarness(24377): at com.jme3.asset.DesktopAssetManager.loadModel(418)

02-01 13:39:04.337: E/AndroidHarness(24377): at com.zztest.Main2.simpleInitApp(24)

02-01 13:39:04.337: E/AndroidHarness(24377): at com.jme3.app.SimpleApplication.initialize(231)

02-01 13:39:04.337: E/AndroidHarness(24377): at com.jme3.system.android.OGLESContext.initInThread(261)

02-01 13:39:04.337: E/AndroidHarness(24377): at com.jme3.system.android.OGLESContext.onSurfaceCreated(212)

02-01 13:39:04.337: E/AndroidHarness(24377): at android.opengl.GLSurfaceView$GLThread.guardedRun(1348)

02-01 13:39:04.337: E/AndroidHarness(24377): at android.opengl.GLSurfaceView$GLThread.run(1118)



Any help would be much appreciated…

just use the recommended jmp for this, then you wont run into any problems. I’ve just started android app development, and never used eclipse (recommended for android app development) until yesterday, and its basically the same, just a few hotkey changes and your set. It saves you a lot of trouble in the long run

Eclipse deploys your binaries in a ./bin/ folder by default, but when it starts your application, the working directory is actually Eclipse in Program files.



I suppose the assetManager is looking for your model in C:Program FilesEclipsemodelteapot.j3o



You should configure the assetManager using an absolute path. There are various ways to do this. One is :

[java]String currDir = new File(".").getAbsolutePath();[/java]

or

[java]System.getProperty("user.dir")[/java]

On a side note, this forum doesn’t like backslashes x.x

Thanks for your suggestion. The jME SDK is great to use but I’m also trying to grasp why jME can’t load the model when I compile from Eclipse.



I have found that if I substitute an alternate version of jME-core.jar for the version taken from the latest nightly build, it works. The (I assume) older version is taken from the SDK build. So it isn’t a path issue, it seems to be a difference in the way the latest version of jME-core handles the .j3o model file.



Any idea what’s wrong?

your assets folder isn’t on the class path

Thanks for the various replies.



When I substituted an older jME-core.jar for the version contained in the nightly build, it worked. Doesn’t that mean that it can’t have been a problem with the classpath? That is, the assets load.



Why does the newer jar have trouble? Does the asset manager it contains fail to search the assets folder?

Do you correctly register your path in the assetManager ?

[java]assetManager.registerLocator( “./assets/”, FileLocator.class.getName() );[/java]



I think the starting dot is important to tell the manager you want to look in current’s folder.

1 Like