Accessing the AndroidAssetManager from a regular activity

Hey there. I plan on doing some pre-loading of my 3D models on android.

But I can’t seem to figure out how to handle the AndroidAssetManager.



In my main activity which is shown before the AndroidHarness activity I have created a thread which should load the model



[java]class ModelLoader extends Thread {

public void run() {

assetManager = new AndroidAssetManager();

carNode = (Node) assetManager.loadModel(“assets/BMW_3_2012_sedan_LOW.j3o”);

Log.e(“DEBUG”, “LOADING DONE”);

}

}[/java]



Now, the only problem is, It never reaches “LOADING DONE”…



Did I miss something regarding how JME handles the assetManagers?

Just use the one in application, its not any different from desktop.

I need to get the assetManager before the SimpleApplication is even created.

the SimpleApplication should then fetch it from my main activity.

Why? I think thats a design flaw. If the simpleApplication isn’t running yet your preloading will only work for android and no other platform, just do the preloading like you would in a normal application (see wiki) and you app will run on any platform thats supported or supported in the future.

Well… the android app consist of several activities, and loading the model takes a while due to the size.

I just want the model to be ready when/if the user reaches the activity where the model is showed.

There is no need to think in Activities too much when using jME3, just create the game like you would for any platform, theres solutions to switching screens, AppStates etc built-in and these work across platforms. Android-specific code should only be needed for android-specific things that need to be done on the android side in order to get the functionality to work.

I have a complete app, and I just integrated a SimpleApplication into a FrameLayout.

This is not a game, it just displays a 3D model over my existing layout.

So make the whole loading screen wait for the app to start and report that it successfully loaded the model :roll: