Using OrderedGroup

Hi guys!

Quick question…
I need one opaque shape to be always rendered in front of another one… How would you normaly achieve that?

I thought OrderedGroup is aimed to be for that… but can’t get it working… It just behave for me like a normal group no matter what order objects are in… ???

Is there anything specific about OrderedGroup?

Will appreciate your help…
Bohdan.

Is your other shape transparent ?

No, both are opaque…

The one that should be rendered in the back - I’d like to stay opaque. The one in front - I don’t mind to make transparent if this can help…

look at my fun with texture example on xith site.

Ordered group is rendering order I also assumed it would overlay two thing iin the same location, in my example I raised the transparent quads a tiny bit to get the correct behavior.

http://xith.org/tutes/GettingStarted/html/more_fun_with_textures.html

So one really has to raise the transparent quad?
But then it also works without an OrderedGroup.
This topic is still a mysterie to me…

Arne, you use that for terrain, right ?
I saw they were bugs when you were far from it.

yep - full hit.

;D Ok. Anyone, no idea what is wrong ?

Hi,

[quote]Ok. Anyone, no idea what is wrong ?
[/quote]
I exactly know what is this.

Transparent and opaque shapes are rendering IN DIFFERENT PASSES by default - first opaque, and then transparent. All the shapes, including those in ordered groups, are split for passes, so ordering is keeping WITHING THE PASS.

Correct solution is to place opaque shapes into transparent rendering pass, or transparent shapes into opaque rendering pass (for example by TransparencyAttributes.setSortEnabled) - check JavaDocs. RenderAtom.isTranslucent() defines if the atom should be rendered on Transparent or Opaque pass - for those who would like to dig into renderer.

Yuri

Ok… but what is the story then if I have only opaque or only transparent shapes in the OrderedGroup…?
In my case this is exactly like that - I have 2 opaque shapes and OrderedGroup is still not working for me…

Bohdan.

Yuri, it’s what I thought first but actually Bohdan has 2 opaque shapes.

Bohdan, try DecalGroup… it has the same description in Javadoc and I don’t know the difference but it’s something to try.

Yes, thanks. I have actually tried DecalGroup in the first place (as I discovered it first while reading Hawkwind’s “More fun with textures”). It didn’t work for me, so I found OrderedGroup then but neither of them worked…

Actualy I don’t remember where, but it was mentioned that DecalGroup is kept only for some kind of compatibility regarding Java3D smth… not too sure…

OK,

Then I prefer to fall back to formal answer: we need a test case, please. As short as possible, as few shapes as possible, etc. etc. etc.

After I will try to track it down.

Post it either in IssueZilla or here.

Yuri

mmh I now made a simple example, but there it works :-
I ofcourse again tested it again with my other code, but it doesn’t work there - so my example is probably to simple.
I’ll next try something, where the layers also have different TextureUnitStates… maybe there’s the problem … I’ll keep you informed.

Thanks arne.
Reported on : http://www.java-gaming.org/forums/index.php?topic=12972.0

Here is another very simple test:
Two opaque shapes in OrderedGroup are located and sized so, that it is easy to test the order.
As you can check OrderedGroup doesn’t work here…


import javax.swing.JFrame;
import javax.vecmath.Vector3f;

import com.xith3d.render.CanvasPeer;
import com.xith3d.render.RenderPeer;
import com.xith3d.render.jsr231.RenderPeerImpl;
import com.xith3d.scenegraph.BranchGroup;
import com.xith3d.scenegraph.Canvas3D;
import com.xith3d.scenegraph.Locale;
import com.xith3d.scenegraph.OrderedGroup;
import com.xith3d.scenegraph.Shape3D;
import com.xith3d.scenegraph.View;
import com.xith3d.scenegraph.VirtualUniverse;
import com.xith3d.test.TestUtils;

public class OrderedGroupTest {
    
    public OrderedGroupTest() {
        JFrame frame = new JFrame("OrderedGroupTest");
        frame.setSize(500, 500);
        //======= setting up Universe ===============
        VirtualUniverse My_Universe = new VirtualUniverse();
        Locale locale = new Locale();
        My_Universe.addLocale(locale);
        BranchGroup scRootBG  = new BranchGroup();
        locale.addBranchGraph(scRootBG);
        //------------------------------
        RenderPeer renderPeer = new RenderPeerImpl();
        CanvasPeer canvasPeer = renderPeer.
                       makeCanvas(frame.getContentPane(), 0, 0, 32, false);
        Canvas3D scrCanvas = new Canvas3D();
        scrCanvas.set3DPeer(canvasPeer);
        //------------------------------
        View scView = new View();
        scView.addCanvas3D(scrCanvas);
        My_Universe.addView(scView);
        scView.getTransform().setTranslation(new Vector3f(0,0,3));
        //======= adding OrderedGroup ===============
        Shape3D cube = new Shape3D(TestUtils.createCubeViaTriangles(0, 0, 0, 1.5f, true));
        Shape3D sphere = new Shape3D(TestUtils.createSphere(1f, 16));
        OrderedGroup ordGR = new OrderedGroup();
        //--- here play with order ------
        ordGR.addChild(cube);
        ordGR.addChild(sphere);
        //-------------------------------
        scRootBG.addChild(ordGR);
        //======= running =============================
        frame.setVisible(true);
        while (frame.isVisible()) {
            scView.renderOnce();
        }
        System.exit(0);
    }   
    
    public static void main(String args[]) {
        new OrderedGroupTest();
    }
}


Bohdan

P.S. Changing OrderedGroup to DecalGroup makes no diference.

mmh I only tested, when the different shapes were at exactly the same location (and I already had problems with that)

actually I’ve to admit - if OrderGroup or DecalGroup would have worked correctly, my code wouldn’t have given me a result I would have liked - not that it did anyways

Is it possible to make a real DecalGroup(I mean where the rendering order is only important when the faces are exactly on the same place - so decals could also work for non-convex shapes)

I was able to validate your results with my test case, too. Seems I just had luck ::slight_smile:

I’ve traced it down a bit:
OrderedGroup --instanceof tests–> Node -> OrderedState -> Renderer Stuff

and there ends my knowledge.

@bohdan: what renderer are you using?

I am using com.xith3d.render.jogl

can anyone please test this with lwjgl and jsr231 please?