Funny behavior with InstancedNode attached to GUI node

SO I figured I would upgrade the game to use InstancedNode everywhere because … why not? It’s cool and it’s optimized. Everything went perfectly until I decided to use and InstancedNode for all my in scene ship indicators that get rendered on the gui node. When I create an InstancedNode, add children, and attach it to the gui node it does not appear. I tried everything … positioning it at 200,200,0.9999, setting everything to the GUI bucket, making sure everything has a cull hint of never, etc… When I take the children of the InstancedNode and attach them to the gui node directly they work. I even tried the InstancedNode WITHOUT calling the instance() method … still no go.

Am I going crazy or have someone else run into this problem? I spent all day debugging this with ZERO results. I am running of 3.1-a3 by the way.

I don’t use these classes but if I were, something I’d check is the location and computed bounding shape of the InstancedNode. It’s possible that it’s moving them somewhere strange. I had this problem with BatcnNode changing the root-level origin of my subgraph and confusing all kinds of things. I don’t know if InstanceNode has the same problem or not.

InstancedNode extends BatchGeometry so maybe.

This sample application works:

import com.jme3.app.SimpleApplication;
import com.jme3.scene.instancing.InstancedNode;
import com.jme3.ui.Picture;

public class TestOrtho extends SimpleApplication {

    public static void main(String[] args) {
        TestOrtho app = new TestOrtho();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        InstancedNode in = new InstancedNode("IN");

        Picture p1 = new Picture("Picture");
        p1.move(0, 0, -1); // make it appear behind stats view
        p1.setPosition(0, 0);
        p1.setWidth(settings.getWidth() / 2);
        p1.setHeight(settings.getHeight());
        p1.setImage(assetManager, "Interface/Logo/Monkey.png", false);
        p1.getMaterial().setBoolean("UseInstancing", true);

        Picture p2 = (Picture) p1.clone(false);
        p2.setPosition(settings.getWidth() / 2, 0);

        in.attachChild(p1);
        in.attachChild(p2);
        in.instance();

        guiNode.attachChild(in);
    }
}

Now try moving each geometry independently in different directions in the update loop.

Each geometry is moving independently in different directions in the update loop:


import com.jme3.app.SimpleApplication;
import com.jme3.scene.instancing.InstancedNode;
import com.jme3.ui.Picture;

public class TestOrtho extends SimpleApplication {

    private Picture p1, p2;

    public static void main(String[] args) {
        TestOrtho app = new TestOrtho();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        InstancedNode in = new InstancedNode("IN");

        p1 = new Picture("Picture");
        p1.move(0, 0, -1); // make it appear behind stats view
        p1.setPosition(0, 0);
        p1.setWidth(settings.getWidth() / 2);
        p1.setHeight(settings.getHeight());
        p1.setImage(assetManager, "Interface/Logo/Monkey.png", false);
        p1.getMaterial().setBoolean("UseInstancing", true);

        p2 = (Picture) p1.clone(false);
        p2.setPosition(settings.getWidth() / 2, 0);

        in.attachChild(p1);
        in.attachChild(p2);
        in.instance();

        guiNode.attachChild(in);
    }

    @Override
    public void simpleUpdate(float tpf) {
        p1.move(-tpf * 20f, 0, 0);
        p2.move(0, tpf * 20f, 0);
    }
}

Strange. Then it must be something with my code. I do complicate things a bit with stacked JavaFX / Lemur and tonegodgui all at the same time. I am stripping out the tonegodgui stuff this week and I will try it again next week. Probably a z order issue on my end. Thanks.

EDIT: Actually wait! I re-instance after each add so that might be it.