Lemur Panel always above 3D model?

I’m trying to have a lemur panel be the background of my GUI, but no matter how I play with the z-depths, it covers the 3d model.

Here’s before the background:

And here is after:

The background that you see is supposed to extend all the way to the bottom, but I made it half so you can see what I am talking about. You can see how the GUI is not covered, but for some reason the model is.

I’ve created the panel like this:

QuadBackgroundComponent fullbg = new QuadBackgroundComponent(assetManager.loadTexture("Textures/inflicted.png"));

Panel bgWindow = new Panel(width,height/1.5f, ColorRGBA.Blue);
guiNode.attachChild(bgWindow);
bgWindow.setLocalTranslation(0f, (float) height, -20);
bgWindow.setBackground(fullbg);

And the model is placed in like this:

vehicle = assetManager.loadModel("Models/rally_car.mesh.j3o");
    vehicle.rotate(0,(float)-PI/(float)4,0);
    vehicle.setLocalTranslation(-1, -1.5f, 1);
    rootNode.attachChild(vehicle);

I’ve played with the z-depths; I’m not sure how to proceed.

That’s because JME’s GUI ViewPort is in front of the 3D ViewPort. So it will always be drawn on top.

If you need 3D objects in front of 2D UI then you can try placing a 2D ViewPort behind the regular scene, or more commonly place a 3D ViewPort in front of the GUI ViewPort.

It’s not really a Lemur-specific issue as this would affect anything in the guiNode/gui ViewPort. Once you get your ViewPorts sorted out then things should work.

Note: managing a custom view port requires some extra stuff since you’ll have to call updateLogicalState() and updateGeometricState() yourself on the ViewPort’s root(s). An AppState is the best way to handle this and there have been several examples on the forum before.

Edit: and also note, if you need Lemur’s picking in the new ViewPort there is an easy method on GuiGlobals (I think) to add new viewports and/or root nodes. If it’s not there then it’s on the MouseEventState.

Awesome, that got me pretty far. For now, I just did a “hack” by attaching the 3d model to the guiNode and scaling it differently. However, now it is semi-transparent in some sense. Like, parts they shouldn’t be seen are seen:

It looks weird because some parts that are visible shouldn’t be.

I think I read something about this, but I don’t remember reading a fix. Does this have to do with orthographic projection?

EDIT: I just stumbled upon this thread which may or may not make things easier, I’m not sure.

EDIT EDIT: Is something getting culled by the camera?

The guiNode flattens Z when rendering… like scales it to 0. (Z is only used for ordering.) So for a lot of models they will render very strangely.

mhhhhhhhhhhmmm. I had a feeling.

I’m now trying to create a new 3d viewport to put over the gui layer, but I’m struggling:

    Camera cam2 = cam.clone();
    ViewPort top3d = renderManager.createMainView("top 3d layer", cam2);

I’m having real difficulty finding documentation for adding viewports. From what I gathered, I add a camera and then create a viewport using that camera. But how do I ensure that this 3d viewport is over the GUI? Where is the “order” of the layers determined?

The order is determined by the order they are created. But the gui viewport is a post view… so if you want something on top of it then you will also have to create a post view.