Load model without application class

Hi, I want load my model without application class, becouse I want use this Engine only in Server logic without rendering.



[java]public class Main {



public static void main(String[] args){



DesktopAssetManager assetManager = new DesktopAssetManager();

Spatial ninja = assetManager.loadModel(“ttt.obj”);

}



}[/java]



INFO: DesktopAssetManager created.

Exception in thread “main” java.lang.IllegalStateException: No loader registered for type “obj”

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

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:376)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:386)

at Main.main(Main.java:28)





And how I can use Mesh in the class Spatial?

1 Like

Just create a headless server. https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:headless_server

1 Like

The default constructor does not initialize the handler of the DesktopAssetManager.

Have a look at the source code:

[java]public DesktopAssetManager(){

this(null);

}[/java]



[java]public DesktopAssetManager(URL configFile){

if (configFile != null){

loadConfigFile(configFile);

}

logger.info("DesktopAssetManager created.");

}[/java]



So:

[java]DesktopAssetManager assetManager = new DesktopAssetManager(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg"));[/java]

Maybe is a better solution as you can ignore the inheritance of the jmonkey Application.



I guess nobody can answer why they provide such a default constructor for the DesktopAssetManager.

Cause you’re supposed to use JmeSystem.newAssetManager();