AssetManager.LoadAsset seems broken after update

Hi,



First thx for this great tool and platform :slight_smile:



I just did an update and one of my stuff is broken.

Looking deeper I have noticed the following



I am using AssetManager.loadAsset to load some saved Terrain

like assetManager.loadAsset(“Models/Terrain/13.j3o”);



and it fails now with

java.lang.IllegalArgumentException: Model assets must be loaded using a ModelKey

at com.jme3.export.binary.BinaryImporter.load(BinaryImporter.java:106)

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

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



in DesktopAssetManager we can see



public Object loadAsset(String name){

return loadAsset(new AssetKey(name));

}

which loads after using Binary importer load using AssetInfo



but it seems there is now a check on Key and only a ModelKey is allowed

in Binary Importer

public Object load(AssetInfo info){

if (!(info.getKey() instanceof ModelKey))

throw new IllegalArgumentException(“Model assets must be loaded using a ModelKey”);







So is that on purpose? will the LoadAsset be decomissed at some point? and should I use the binaryImporter directly for all Non Model?

or was I doing something wrong at start?

If you know you’re loading a model, either use a ModelKey or the loadModel() method to load it.

I am not loading a Model, but a saved TerrainQuad

So was using LoadAsset since ModelKey force a clone at the end to get ‘Model’ and the clone method for terrainquad is

@Override

public Node clone(){

//TODO use importer and exporter to clone it

return null;

}



So to load a Saved Terrainquad, I was using loadAsset which is not working anymore, because it uses a AssetKey, and BinaryImporter want a ModelKey for : public Object load(AssetInfo info){



So since the update , I need to use locateAsset and use directly Binaryimporter with the opened stream.

@Momoko_Fan: Why is ModelKey not an AssetKey<Spatial> btw?

though was for me sorry :slight_smile:



ModelKey would work if it was not doing that

@Override

public Object createClonedInstance(Object asset){

Spatial model = (Spatial) asset;

return model.clone();

}

as Clone method of TerrainQuad returns null…



My main Problem is that I cannot load a TerrainQuad Anymore using assetmanager



if I use loadAsset I get the Exception that I cannot use it since it uses AssetKey and BinaryImporter.load(AssetInfo info) only wants a ModelKey

if I use loadModel, I get null because of TerrainQuad.clone

@pitoui: Well, theres no use doing it wrong just because something else is missing. The clone() method will be implemented for Terrain as well, so you’ll have to wait until that works to save Terrain. Its also one of the reasons why Terrain editing and saving is not yet implemented in jMP. @Momoko_Fan: But my question still stands… :slight_smile:

thx a lot . Will use my work around then in mean time.

I wonder why brent said that importer/exporter should be used to clone it? Is there some issue with cloning terrain?