Re: Problem with displaying the line segments
Posted by
philjord on
Apr 26, 2017; 6:30am
URL: https://forum.jogamp.org/Problem-with-displaying-the-line-segments-tp4037890p4037896.html
world,
I'm pretty sure this is related to the OpenGL fixed function pipeline issue of having no transparent triangle sorting strategy, whereas DirectX does. Though I'm not sure if you are using the DirectX dll behind java 1.5.2 because I couldn't find a release with it in it.
Anyway I can get the expected rendering simply by commenting out the line
lineAttr.setLineAntialiasingEnable(true);
Because anti-aliasing forces lines to be in the transparent pass, and therefore they don't write to the depth buffer and hence get mixed with other transparent renders. Note that the centroids of all your shapes are the same so geometry sorting won't help here.
If you want to keep them nicely anti-aliased (and who wouldn't) then you need to reorganize your scene graph using an OrderGroup to make the lines render after the boxes in the transparent pass
So I added a new member
private SimpleUniverse universe;
private BranchGroup root;
private TransformGroup trans;
private OrderedGroup og = new OrderedGroup();
added it to the trans group
trans = new TransformGroup();
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
trans.addChild(og);
root.addChild(trans);
and put the line box into it, instead of trans
trans.addChild(new Box(w, w, w, app));
//trans.addChild(lineShape(w, lineColor));
og.addChild(lineShape(w, lineColor));
You may already know this but this two items are also a good idea.
view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
System.setProperty("sun.awt.noerasebackground", "true");
Please have a go and tell us if it helps,
Phil.