3D models not properly rendered inside GUI viewport

Hello guys

I was trying to implement a simple gui displaying 3D rotating model at the center of the screen.

I could do it without problem, but I saw a graphical depth trouble during the rotation, for example for this man I see his eyes throught his head, and shirt rendered behind his body… stuff like these…

Code is following

[java]
Spatial revolverSpat = (Spatial) assetManager.loadModel(“Models/TP/TP.mesh.j3o”);
testNode = new Node(“test”);
testNode.attachChild(testSpat);
testNode.depthFirstTraversal(
new SceneGraphVisitor() {
@Override
public void visit(Spatial s) {
s.setQueueBucket(RenderQueue.Bucket.Inherit);
}
});
testNode.setQueueBucket(RenderQueue.Bucket.Gui);
guiNode.attachChild(testNode);
guiNode.addLight(envLight);
guiViewPort.setClearFlags(true, true, true);

[/java]

Do you know how to solve this problem?

Thank you!

The gui node uses a parallel projection, which doesn’t have the concept of depth. Use another viewport for this instead

1 Like

Thank you very much, I will try it

1 Like