[SOLVED]materials in beta

how to load material now? or just what to change IN material?



Material mat = (Material) assetManager.loadAsset(“Materials/cobblestone.j3m”);





this method seem not to work:



com.jme3.asset.AssetLoadException: An exception has occured while loading asset: Materials/cobblestone.j3m

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

at com.jme3.material.Material.(Material.java:128)

at oxplay.Client$ChooseMap.init(Client.java:814)

at oxplay.Client$ClientState.updateMapState(Client.java:1227)

at oxplay.Client$ClientState.updateStates(Client.java:1266)

at oxplay.Client.applicationUpdate(Client.java:1305)

at oxplay.app.engine.GameApplicationExtend.simpleUpdate(GameApplicationExtend.java:47)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:255)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Thread.java:619)

Caused by: java.io.IOException: Material instances must be loaded via MaterialKey

at com.jme3.material.plugins.J3MLoader.load(J3MLoader.java:535)

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

… 11 more

Probably a texture in the j3m is wrongly referenced or it uses a deprecated MaterialDef? I can load normal j3m files properly.

1 Like

if it would be wrong referenced then i should not have image of texture editing it yes? :> (its great what you added in beta :))





About deprecated MaterialDef it use Common/MatDefs/Light/Lighting.j3md

If you can edit it it can be loaded, you sure you do everything correctly there?

Caused by: java.io.IOException: Material instances must be loaded via MaterialKey
1 Like

it’s true :slight_smile:



Thanks for help :slight_smile: i thinked if in tutorial is:


myGeometry.setMaterial(assetManager.loadAsset("Materials/SimpleBump.j3m"));


then it's ok,
but it wasn't.

Ummmm… why are you doing:

Material mat = (Material) assetManager.loadAsset(“Materials/cobblestone.j3m”);



When you could do:

Material mat = assetManager.loadMaterial(“Materials/cobblestone.j3m”);

oO In what tutorial is that? We should change that then. The Material tutorial uses the Material constructor… Does that code work at all? loadAsset returns a Spatial… Theres loadMaterial() though, which should also work fine…

here:



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:j3m_material_files?s[]=assetkey





and propably that code was working in alpha, not beta ;p

1 Like

loadAsset() returns an object (not spatial) because that’s what you would use to load a custom asset that you have your own loader for.



But, some point in the last six months I guess loading materials became more complicated and now requires a MaterialKey if you want to load it inconveniently. Or just use loadMaterial(). :slight_smile:



…so one of the tutorials must need updating.

1 Like

Alright, thanks. Updated the wiki page.

Edit: Oh and I meant Savable… But yeah, its actually an object…