[SOLVED] Can't load models properly on guiNode

So, ATM I’m focusing on designing the GUI for my strategy game, and I decided to mix Nifty GUI and vanilla guiNode. I load 3D models on guiNode and place them on top of the Nifty GUI’s panels to “kinda” merge the two. I know I can do it in another way (I think it’s related to FrameBuffers), but I want to try and see if it works well for me.

The problem is, when loading the model, weird stuff happens (don’t worry about the position of the models):

I know that this is happening due to using Hardware Skinning, instead of Software Skinning. I think Blender didn’t export correctly or something, but that is an issue that I’ll fix later. For now, I set the models to use Software Skinning.

However, in the guiNode, it seems it’s not working, even if I’m setting that option on the SceneExplorer. So to make the model look normal, I have to manually change the skinning method in the code. Doing that fixes the model’s look:

But that is just part of the problem. When I rotate the model, I realise it’s depth is not being calculated, as if DepthWrite was deactivated (which is not):

I try and fix this the same way I fixed the Hardware Skinning problem:

public static void enableDepthWrite(Spatial spat) {
    if(spat instanceof Node) {
        Node n = (Node)spat;
        for(Spatial s : n.getChildren()) {
            enableDepthWrite(s);
        }
    } else if(spat instanceof Geometry) {
        Geometry g = (Geometry)spat;
        g.getMaterial().getAdditionalRenderState().setDepthWrite(true);
        g.getMaterial().getAdditionalRenderState().setDepthTest(true);
    }
}

But it doesn’t work. I recall a long time ago loading 3D models on the GUI and I never have had this issue before. Did any of this happen to you? How do I fix it?

Thanks,
Ev1lbl0w

Not exactly sure about that, but I think the guiViewPort doesn’t even have a depth buffer, only back-to-front-sorting.
It also uses parallel projection. In any case, the guiNode is not suitable to render 3D stuff.

You can render your models to a texture in a separate viewport and place it in the gui node with a quad. Or pass that texture to a Nifty object, but for that you have to disable Nifty’s texture atlas by using another constructor of NiftyJmeDisplay.

Or render the models directly on the screen with a separate viewport. That might be the easiest way in your case.

The guiNode’s issues have nothing to do with parallel projection. A viewport with parallel projection would show these models just fine.

It’s the Gui BUCKET that flattens depth. The guiNode is in the Gui BUCKET… which is why 3D models render funny there. It’s not the fault of a the viewport.

So, my only chances are rendering the object to a quad and show it on guiNode?

If you MUST show it on the guiNode then yes. But I don’t know why you MUST show it on the gui node or in the gui bucket.

There are several other options mentioned that don’t involve the gui node.

a.k.a make a new viewport that doesn’t clear color and renders after the guinode.

If you MUST show it on the guiNode then yes. But I don’t know why you MUST show it on the gui node or in the gui bucket.

a.k.a make a new viewport that doesn’t clear color and renders after the guinode.

Ok thank you guys xD!