jME3 Model Importing

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:







And here is the code:



import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;

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?

Try this in the Eclipse version… my guess is that the assets folder isn't directly on your classpath


 player = (Node) assetManager.loadModel("assets/Models/Oto/Oto.mesh.xml");

Thank you. That worked!

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?






 
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
 
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)

That sounds kind of strange… I would try using a JFileChooser to select the model URL and seeing what the deal is

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 wonder if eclipse has such option.

yes, else using jme3 would be a pain in the ass ^^ Also i can get rid of android stuff that way.

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?

right click on project, properties, build path, add all needed folders there, source folders get copyed and or compiled to bin then.

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!