[New] Trouble when check the picking results & [SOLVED] Trouble in putting many models(will be operated) together

I am a beginner in JAVA, and I’m going to use JME to develop a 3D minesweeping game. Now I got a question.

When I generate minefields, since the size and distribution of minefields are not fixed while each grid will be operated in the process of the game, I want to make the grid state to be a class. Then, at the beginning of the game, we load the existing models (obj.&mtl.) according to the state of each grid, then put them together to form a complete minefield. But in all the tutorial I could find, only a single model can be loaded, and I can’t do that as mentioned above. So, I would like to ask for a solution to this problem.

Very appreciated! ( It’s better to offer a sample program as reference.)

Hi @BAO , welcome to jme community, I don’t know from where should I begin, but at least you can navigate the jme3 wiki & search for :

  • Importing Assets
  • BaseAppStates
  • AbstractControls

There are multiple ways to do that, one way is using a BaseAppState & a synchronized time frames within the update which kinda sleeps some frames from a model to other , so

  • you build a list of models, called Tiles[].

  • synchronize them inside the update method with time frames.

  • you can do this too with only time frames w/o a synchronized block anyway.

Example :

Tips : you can do display a SplashScreen or LoadingScreen whenever you are doing a heavy task to hide the ugliness of low fps…

Did you do all of the tutorials here:

…or only the first one or two?

Actually, even the second tutorial has more than one object in the scene.

I’m now try to use a Spatial list called temp[][] to load my models. However, I can’t solve the error when load my model.
This is the report:

Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ClassCastException: class com.jme3.material.MaterialList cannot be cast to class com.jme3.asset.CloneableSmartAsset (com.jme3.material.MaterialList and com.jme3.asset.CloneableSmartAsset are in unnamed module of loader ‘app’)
at com.jme3.asset.cache.WeakRefCloneAssetCache.addToCache(WeakRefCloneAssetCache.java:127)
at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:294)
at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
at com.jme3.asset.DesktopAssetManager.loadMaterial(DesktopAssetManager.java:412)
at Main.simpleInitApp(Main.java:41)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:139)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
at java.base/java.lang.Thread.run(Thread.java:832)

Could you tell me what is the problem? Very Appreciated!

This is the source code(It hasn’t done yet):

First of all, why you do:

Material materialGrass = assetManager.loadMaterial(“Assets/Models/Grass/Grass.mtl”);

.obj loader will load it itself as i remember? Also it might cause that issue.

Anyway GLTF is suggested format(its a new Standard), and best if converted into j3m. If you want load separate materials you can make j3md/j3m files.

Second thing is that you dont even need

Spatial [][]temp


Status [][]status

you can just use Node with subSpatials and setUserData/getUserData on them.

BEST if you would use ECS, but its too early stage for you i belive.

Also it would be very helpfull for you to know things like AppStates/etc

Yeah, in JME MaterialList doesn’t implement those clonable things. I guess it is never meant to be used like that. I didn’t check the usage, but maybe it is just specific to that loader MTL. I would imagine it is not a big thing to modify MaterialList to implement the interfaces if it serves the purpose.

Typically in production one should use JME’s own formats for superior performance and compatibility.

So how can I convert that plz? When I open my blender model in the SDK, I only got the option that convert to j3o. Or is j3o also OK?

And any more information for the detailed tutorial about AppStates and subSpatials? I could only find the javadoc but can’t make it clear.

is correct. It is the JME object format.

Could tell me where I can learn about the AppStates & subSpatials? I can only find SimpleApplication in the tutorial (Maybe because of the language barrier)

Really hard to say what you are trying and how your assets work. But probably you can circumvent this problem by converting the assets to J3O. The material might be already attached on the J3O but this is something that you will see then.

A j3o will always have some material. The Geometry objects would be invalid without it.

Could tell me where I can learn about subSpatials?

And how can I use the AppStates? Maybe extends BaseAppState?

Yeh, simply for subSpatials, search for Nodes, BaseAppState search for appstates inside jme3 wiki or jme3 git repo for direct examples…

Wiki link :

this 3 links will help you in General, not to solve issue. To solve issue you need do what i said before.




and here is also important GLTF wiki:

When I convert the blender file to j3o, I got also a j3odata file. What is that about? Shall I load it too?

The SDK keeps these files around for its own purposes. You can ignore them.

But I cannot load models in my BaseAppState. Or shall I write some small app(to load models) with SimpleApplication then manage them in AppState? Could you plz make it more clear to me?

And my plan now is firstly to take every grid to be a class with properties like coordinates & status etc, then I could write a method to load the model of every grid by its property. And I could also write a listener there.

Is there a way to do that?

Yes, you can.


Oh, I mean I cannot use assetmanager