I’m having a frustrating problem with importing models. The exact same code that successfully imports a model in the jME3 Platform won’t work in Eclipse using the latest nightly build. Keep in mind, I directly copied and pasted both the code and the necessary files:
public class HelloAnimation extends SimpleApplication{
Node player;
public static void main(String[] args) {
HelloAnimation app = new HelloAnimation();
app.start();
}
@Override
public void simpleInitApp() {
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());
rootNode.addLight(dl);
player = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
player.setLocalScale(0.5f);
rootNode.attachChild(player);
}
}
When I run this in Eclipse, it crashes with this in the log:
WARNING DesktopAssetManager 9:29:10 PM Cannot locate resource: Models/Oto/Oto.mesh.xml
SEVERE Application 9:29:10 PM Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at HelloAnimation.simpleInitApp(HelloAnimation.java:23)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:147)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:102)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:147)
at java.lang.Thread.run(Unknown Source)
The problem line : player = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
I have no idea why it can't find the model, since the file path is exactly the same after a certain point. Does anyone know what the issue could be?
Another problem… I exported the default cube from Blender to .xml format. It won’t load in either Eclipse or the Platform. To confuse matters further, the previous example loads from the example files, not the model I placed inside the folder. What am I missing?
public class HelloAssets extends SimpleApplication {
public static void main(String[] args) {
HelloAssets app = new HelloAssets();
app.start();
}
@Override
public void simpleInitApp() {
Spatial cube = assetManager.loadModel("assets/Models/Cube/Cube.mesh.xml");
rootNode.attachChild(cube);
// You must add a light to make the model visible
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
rootNode.addLight(sun);
}
}
WARNING DesktopAssetManager 11:07:47 AM Cannot locate resource: assets/Models/Cube/Cube.mesh.xml
SEVERE Application 11:07:47 AM Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.scene.Node.attachChild(Node.java:242)
at HelloAssets.simpleInitApp(HelloAssets.java:17)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:147)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:102)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:147)
at java.lang.Thread.run(Unknown Source)
I don't know how it is in eclipse, but in NetBeans you can add the "assets" folder to be a "source package", so it is automatically compiled and included with the classpath.
I feel stupid mentioning this now, but I never told Eclipse to add anything to the build path. I figured assetManager would find it no matter where it was, but I guess not. How do I add the assets folder in Eclipse?
No good, I get the same error even when the file is visible in the package viewer. It doesn't get copied to the bin folder. And either I'm going crazy, or the previous code that uses the example mesh won't work either since the latest nightly build!