Cannot load model

Hello,

I’m pretty new to nifty and I think I’m missing something obvious. I try to set up a GUI. It contains a button called view, when I’m clicking on it a model should appear.

I’ve got two classes. The first one is the Main , it sets up the GUI:
[java]public class Main extends SimpleApplication implements ScreenController {
Nifty nifty;
Screen screen;

@Override
public void bind(Nifty nifty, Screen screen) {
	 this.nifty = nifty;
	 this.screen = screen;

}

@Override
public void onEndScreen() {
	// TODO Auto-generated method stub

}

@Override
public void onStartScreen() {
	// TODO Auto-generated method stub

}

@Override
public void simpleInitApp() {
	NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager,
			inputManager, audioRenderer, guiViewPort);
	//Create a new NiftyGUI object */
	Nifty nifty = niftyDisplay.getNifty();
	//Read your XML and initialize your custom ScreenController
	nifty.fromXml("Interface/screen.xml", "start", this);
	// attach the Nifty display to the gui view port as a processor
	guiViewPort.addProcessor(niftyDisplay);
	// disable the fly cam
	flyCam.setDragToRotate(true);

}
public void showAnim(String nextScreen) {
	System.out.println("Changing Screen");
	nifty.gotoScreen(nextScreen);
	Mesh mesh = new Mesh(this);
	mesh.startAnim(nextScreen);
	nifty.exit();
}
public static void main(String[] args) {
	Main main = new Main();
	main.start();
}

}[/java]

the second class, should be able load the mesh and to animate it later on, right now I’m just trying to load it.
[java]public class Mesh {
protected Main app;

public Mesh (Main app){
	this.app = app;
}

public void readingOgreMesh(AssetManager as, Node rootNode) {
	System.out.println("In the function");
	// Reading Mesh from File
	Node face = (Node) as.loadModel("Models/denz.mesh.xml");
	System.out.println("Did it");
	// Keep Offset to camera
	face.setLocalTranslation(0f, 0f, -60f);
	System.out.println("Try attaching child");
	rootNode.attachChild(face);
}

public void startAnim(String nextScreen){
	System.out.println("Hello");
	AssetManager as = app.getAssetManager();
	Node node = app.getRootNode();
	readingOgreMesh(as, node);
}

}[/java]

My screen.xml looks like this

Right now JME is only showing a black screen, when clicking on the View-Button. What am I doing wrong?
Thank you in advance!

How stupid! I’m sorry! I forgot to turn on the lights!

1 Like