Hi, I was trying to get Nifty to work after I made a small world. Nifty now works great, but I’ve been unable to show my objects on the gamescreen.
I’ve added a few blocks on various positions and checked if they were being attached to the node or not. They were being attached as I looked at the console and found: INFO: Child (box) attached to this node (Root Node)
They however did not appear on the screen.
I’ve also tried adding some guiding lights like a sun, but these also didn’t appear on the screen.
The camera however is being attached to my ‘player’-model as seen in the console: INFO: Child (Camera) attached to this node (data/models/Box.blend).
When loading the xml file for Nifty and going to the ‘Game’, that works, as there is a button added in the xml and that button does appear on the screen.
After eliminating all these possible problems, I have no clue where to look next, I hope you can help me
Here’s the code:
Main:
[java]public class Main
{
private static MainApplication game;
public static void main(String[] args)
{
game = new MainApplication();
game.start();
}
public static MainApplication getGame()
{
return game;
}
}[/java]
MainApplication:
[java]public class MainApplication extends SimpleApplication
{
public MainApplication()
{
super();
}
@Override
public void simpleInitApp()
{
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
Nifty nifty = niftyDisplay.getNifty();
nifty.fromXml("data/gui/screens.xml", "game");
guiViewPort.addProcessor(niftyDisplay);
inputManager.setCursorVisible(true);
}
//simpleUpdate left out
}[/java]
GameController:
[java]public class GameController extends AbstractAppState implements ScreenController
{
private Player player;
private World world;
private InputManager inputmanager = new InputManager(this);
public Player getPlayer()
{
return player;
}
@Override
public void bind(Nifty arg0, Screen arg1) {}
@Override
public void onEndScreen() {}
@Override
public void onStartScreen()
{
// Load materials
MaterialLoader.loadMaterials(Main.getGame().getAssetManager());
// Initialize world
player = new Player();
try
{
world = new World(player);
}
catch (Exception e)
{
e.printStackTrace();
}
Main.getGame().getRootNode().attachChild(world.getWorldModel());
Box box = new Box(10, 10, 10);
Geometry geo = new Geometry("box", box);
geo.setMaterial(MaterialLoader.getGroundMaterial());
Main.getGame().getRootNode().attachChild(geo);
// Add to the rootNode, the nodes of the scene and hud
Main.getGame().getViewPort().attachScene(Main.getGame().getRootNode());
//button mapping left out
[/java]