Hi all,
I have an object that I would like to always render on top of the other objects (but not the GUI).
So, even if this object is hidden behind a building, or under water, or in cave, it will still be seen. I was planning to do this by drawing the entire scene, and then rendering the object afterwards.
I have the object set up as a Node, but I can’t seem to get it work. I tried using renderManager.renderScene() after the regular render, but to avail
Can anyone shed some light on how to add my own render pass to do this?
Thanks very much
The best way is to setup a custom ViewPort.
Something like:
[java]
Node root = new Node( "Overlay Root" );
root.setCullHint(CullHint.Never);
Camera overlayCam = app.getCamera().clone();
overlayCam.setLocation( new Vector3f(0, 0, 10) );
…etc…
ViewPort view = app.getRenderManager().createMainView("Overlay", overlayCam);
view.setClearFlags(false, true, false);
view.attachScene( root );
[/java]
Then you just have to remember to call these on update() (or render()):
[java]
root.updateLogicalState(tpf);
root.updateGeometricState();
[/java]
I do mine in an AppState so I do the updateLogicalState() call in AppState.update() and the updateGeometricState() in AppState.render().
What if you disable depth checking for that object?
Ooop… I assumed the object was more complicated than a convex shape and that it might rotate. InShadow is right, though. If you have a simple convex shape and/or a shape that won’t self-occlude when it rotates then you should be able to get away with turning depth testing off.
Thank you pspeed. Your solution was exactly what I was looking for
It’s lucky, because I am not sure how to disable depth checking for an object haha
In case it comes up in the future: material.getAdditionalRenderState().setDepthTest(false)