I’m implemnting an editor based on the following documentation: http://jmonkeyengine.com/documentation/guide.pdf. It is possible to translate, scale or rotate objects. To do this I use (analog to the documentation) gizmos - see picture on page 36. This gizmo must necessarily be completely visible. The documentation (which based in jme2) makes use of the ZBufferState:
ZBufferState zbuffer = renderer.createZBufferState();
zbuffer.setFunction(ZBufferState.TestFunction.Always);// ersetzt immer jeden Pixel!
But I use jme3 and I can not find the class ZBufferState there. Can anyone help me, which class I can use in jme3?
I think have to illustrate my probelm a little bit. The following picture shows my default sphere with a gizmo to scale the object:
It is not so fatal that the gizmo is not completely visible (the sphere overlaps the gizmo) in this picture. The following picture shows the situation witha much bigger sphere:
The sphere overlaps the gizmo almost completely. If the sphere where a little bit larger, the sphere would overlab the gizmo completely.
My question is: What can I do to make the gizmo always visible in the foreground?
I think theres an option for that in material.getAdditionalRenderStates()
I tested a lot with this option, but I can not solve the problem. For the gizmo I tested the following options: “matGizmo.getAdditionalRenderState().setBlendMode(BlendMode.XXX);” and “matGizmo.getAdditionalRenderState().setFaceCullMode(FaceCullMode.XXX);” with XXX = all possible modes. But this shows no effect.
For the sphere geometry objekt I tested the following:
With this option I get the following effect:
Thats almost what I want. But the texture of the sphere is lost. What am I doing wrong?
try to set the depthWrite to false for the gizmo’s materials
If I set this option in get the follwoing situation:
This setting makes the gizmo transparent. Has anyone another idea?
I think that other option (ignore depth buffer) could be also helpful.
Maybe there is a way to modify output z-coordinate of fragment from pixel shader? You would then just push it as much to the front as possible, which together with depth ignore (but with depth write on) should give the proper effect.
try setDepthTest to false and tell me what you got
Hey, thank you. This solves my probem. See the following picture:
To see the grid through the gizmo is not so ideal, but that doesn’t matters, because my main problem is solved!
Maybe try to put the gizmos in the GUI bucket so they are the last rendered. (keeping the depth test to false)
Did you mean the following?
If I try this, the gizmo is not visible.
Well that was a guess…and looking at the code now, it can’t work like this.
you can try to put them in the transparent bucket…but, this would be more of a hack than a real solution.
For me the following worked out:
// Make the line xray mat.getAdditionalRenderState().setDepthWrite(false); mat.getAdditionalRenderState().setDepthTest(false); geom.setQueueBucket(Bucket.Transparent);
Ahem… 5 years later…
Better late than never, amirite?
Maybe somebody looks for it (like me) and finds it here
It’s not really the right answer, though. 5 years ago, even the now-experts weren’t experts and were casting about for imperfect solutions.
In my opinion, if you want something drawn on top of the scene like this then a separate viewport is the best way. You can even still use depth test and depth write if you like… or completely clear the depth of the underlying frame first, still have depth in your second frame, whatever. Very flexible for these sorts of overlays.