Hud clipping problem?

I’ve been doing some work on the HUD for my game, and everything works fine when I use “flat” nodes in the hud - that is, when everything I want to display has no “depth” in the Z axis. Quads with no Z translation work, but if they are translated in the Z axis they disappear. A Sphere is invisible, unless I show polygons, in which case I see a ring which looks like the cross section of the Z=0 plane and the sphere.



Here’s a screenshot of a section of the HUD which should have a quad, a sphere and a rotated open ended cylinder (in polygon render mode):



You can see the quad in the center, which is fine, but the sphere becomes a circle, and the cylinder becomes two lines where it intersects Z=0. The stuff in the bottom right is just a non-hud mesh.



The hud node is just attached to my root node, and set up with the following code:



   //Create alpha state to blend using alpha
   AlphaState as = display.getRenderer().createAlphaState();
        as.setBlendEnabled(true);
        as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
        as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
        as.setTestEnabled(false);
        as.setEnabled(true);
      
        //Create disabled light state, hud nodes will be displayed
        //as unlit colour
        LightState ls = display.getRenderer().createLightState();
        ls.setEnabled(false);
       
        setRenderState(as);
        setRenderState(ls);
       
        //Node uses ortho rendering
        setRenderQueueMode(Renderer.QUEUE_ORTHO);
       
        //Never cull hud items
        setCullMode(Spatial.CULL_NEVER);



Does anyone have any ideas as to how I can display orthographically projected 3D meshes in a HUD? I want to use it for stuff like dials, etc. (the old-style ones made from a rotating cylinder with numbers printed around the outside, spinning around the X axis of the screen).

(Edit) I just tried scaling the sphere/mesh and if they have very low scale in the Z axis they are visible.

In my experience, drawing with ORTHO mode in OpenGL will only show up on the screen at z = 0.  For 3D things I've generally had to do some math to position the object in front of the camera so that it looks like it is in the right spot.  There's probably an easier way though.

renanse is on the right track. The ORTHO rendering mode has its clipping planes at -1 and 1 meaning that any quads (or whatever) not within those bounds will not be rendered. If you want to render in orthogonal mode and still have z-translation, set up your own camera for orthogonal projection (but don't use ORTHO mode) and have the far clip plane moved further away.

Ah great, I was kind of thinking along those lines myself, using setParallelProjection on the camera, but it's good to know that's the right way. Is the current behaviour of the ORTHO the desired behaviour then?



I was going to look at making a render pass to change the camera appropriately then change it back afterwards, not sure if that is the right way but I'll give it a go :slight_smile: