Nifty XML Geometries?

It doesn’t appear at all. And I can’t specify the equivalent of your StartScreenController when creating the Nifty GUI:

[java]screenController = new UIScreenController();

nifty.fromXml(“Gui/gui.xml”, “start”, screenController);[/java]

You’ve named your control definition “geometryImage” but in your screen definition you’ve named your control “uiStar” (and set the id to “geometryImage” instead). The name of a control refers to what type of control it is, e.g. what control definition it should use while the id is to identify this particular instance of the control.

Switch the name and id attributes of your lower control in the screen definition file (gui.xml) so name=“geometryImage” and id=“uiStar” (or whatever you like for the id) and it should call the bind method and thus your initializeParameters method.

1 Like

Alright. I get something (red fills the panel where it’s supposed to go). However, now, as soon as I move the mouse once the screen loads, the app crashes with multiple exceptions. I’ve narrowed it down to the call to getting the geometryImage element (getElement()) returning null. However, I’m also getting an InvocationTargetException before that, in the StarMapController class, in the bind method. See images for details.

Well, I don’t see a getElement() method in your StarMapController and you’re not passing the element to the AbstractController via the bind-method. Perhaps try to call super.bind(element) in your bind method in StarMapController.

1 Like

Well, if he did the same as the example I showed him, it would work.

I haven’t overridden the getElement() method in StarMapController. The getElement() method is being called in the other, subclassing controller, in the initialiseParameters() method:

[java]package ui;

import java.util.Properties;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Sphere;

import de.lessvoid.nifty.Nifty;

import de.lessvoid.nifty.elements.Element;

import de.lessvoid.nifty.screen.Screen;

import de.lessvoid.xml.xpp3.Attributes;

public class GeometryImageControl extends StarMapController implements GeometryImage {

private Geometry geometry;

private Element geometryImage;


public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) {

super.bind(nifty, screen, element, parameter, controlDefinitionAttributes);



public void update(float arg0) {}


public void setGeometry(Geometry geometry) {

this.geometry = geometry;


//float x = geometryImage.getConstraintX().getValue(0.5f);

//float y = geometryImage.getConstraintY().getValue(0.5f);

geometry.setLocalTranslation(1, 1, 1);




public Geometry getGeometry() {

return geometry;



protected void initializeParameters(Properties parameter) {

System.out.println(“TEST TWO”);

geometryImage = getElement().findElementByName(“uiStar”); // getElement() returning null here

float size = Float.parseFloat(parameter.getProperty(“size”));

float r = Float.parseFloat(parameter.getProperty(“colorR”));

float g = Float.parseFloat(parameter.getProperty(“colorG”));

float b = Float.parseFloat(parameter.getProperty(“colorB”));

float a = Float.parseFloat(parameter.getProperty(“colorA”));

ColorRGBA color = new ColorRGBA(r, g, b, a);

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, color);

Geometry star = new Geometry(“starImage”, new Sphere(30,30, size));



System.out.println(“TEST TWO END”);




screen.findNiftyControl(…).getElement(); / screen.findElementByName(…); :facepalm:

1 Like