Ok, I have beefed up the Forground node functionality considerably.
I had to keep the “normal” view support as it turns out the com.xith3d.scenegraph package was using it (and now I think about it there may be some other use-cases which need it). By “normal”, I mean the geometry is rendered like it normally is as if it wasn’t a Foreground node at all, the only difference being that it is rendered last.
I added in “fixed” view support where the view is set to the origin to render the geometry (thus the geometry will always be in the same place) - this is commonly used for HUDs and this is what I needed. I decided to add in “fixed-position” support as well. This is exactly like how the background works, but as a foreground. I figured someone may need this for special application where the user could look around their HUD.
For completness, I added in “fixed” and “normal” view support to background node as well.
If you want to see how it’s done, look at the “display” and “setGLViewMatrix” methods of CanvasPeerImpl.
However, I had to make some alterations so that different nodes would be rendered in the correct view (it is possible to have FIXED and FIXED_POSITION foreground geometry). There were a few different ways of doing this, but to keep the overhead down I decided to simply create a special foreground renderBin just for the FIXED geometry and a second one for the FIXED_POSITION. This way, the view is set, the atoms are rendered and then the view is returned to normal. If an application doesn’t have any such atoms, then it should be absolutealy no different than before (except for maybe an extra boolean comparison).
Example of a very primitive HUD - just a single textured cube. As transparency adds some overhead in Xith3d it is probably better not to have one big quad with a transparent window like this.
To use is quite simple:
just call:
Foreground f = new Foreground(quad, View.VIEW_FIXED);
Where “quad” is your BranchGroup geometry and is added to your scene. Unless you are using transparency, it’s probably a good idea to disable the depth buffer so the foreground is always drawn on top.
Support in the LWJGL renderer was also added.
Enjoy,
Will.