Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Using OrderedGroup  (Read 3970 times)
0 Members and 1 Guest are viewing this topic.
Offline bohdan

Junior Duke




Java-positive...


« Posted 2006-03-15 22:54:08 »

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... Huh

Is there anything specific about OrderedGroup?

Will appreciate your help...
Bohdan.
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #1 - Posted 2006-03-16 17:30:01 »

Is your other shape transparent ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline bohdan

Junior Duke




Java-positive...


« Reply #2 - Posted 2006-03-16 19:54:57 »

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..
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline hawkwind

Junior Duke




Java games rock!


« Reply #3 - Posted 2006-03-17 01:06:53 »

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
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #4 - Posted 2006-03-17 06:57:00 »

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...

:: JOODE :: Xith3d :: OdeJava ::
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #5 - Posted 2006-03-17 16:16:41 »

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

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #6 - Posted 2006-03-17 16:22:12 »

yep - full hit.

:: JOODE :: Xith3d :: OdeJava ::
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #7 - Posted 2006-03-17 16:29:04 »

 Grin Ok. Anyone, no idea what is wrong ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Yuri Vl. Gushchin

Senior Duke




Speak Java!


« Reply #8 - Posted 2006-03-23 09:40:01 »

Hi,

Quote
Ok. Anyone, no idea what is wrong ?
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

Yuri Vl. Gushchin
JProof Group
Offline bohdan

Junior Duke




Java-positive...


« Reply #9 - Posted 2006-03-23 16:37:16 »

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #10 - Posted 2006-03-23 17:31:30 »

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.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline bohdan

Junior Duke




Java-positive...


« Reply #11 - Posted 2006-03-24 00:19:29 »

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..
Offline Yuri Vl. Gushchin

Senior Duke




Speak Java!


« Reply #12 - Posted 2006-03-24 08:11:41 »

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

Yuri Vl. Gushchin
JProof Group
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #13 - Posted 2006-03-24 16:54:25 »

mmh I now made a simple example, but there it works  Undecided
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.

:: JOODE :: Xith3d :: OdeJava ::
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #14 - Posted 2006-03-24 17:23:07 »

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

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline bohdan

Junior Duke




Java-positive...


« Reply #15 - Posted 2006-03-24 19:43:31 »

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...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
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.
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #16 - Posted 2006-03-24 20:53:22 »

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

:: JOODE :: Xith3d :: OdeJava ::
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #17 - Posted 2006-03-24 21:14:47 »

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)

:: JOODE :: Xith3d :: OdeJava ::
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #18 - Posted 2006-03-24 21:27:02 »

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

:: JOODE :: Xith3d :: OdeJava ::
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #19 - Posted 2006-03-24 21:40:20 »

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?

:: JOODE :: Xith3d :: OdeJava ::
Offline bohdan

Junior Duke




Java-positive...


« Reply #20 - Posted 2006-03-24 21:55:45 »

Thanks Arne, for helping!

Yes, I actually originally tested it on jsr231...
Offline bohdan

Junior Duke




Java-positive...


« Reply #21 - Posted 2006-03-24 22:34:07 »

No go on "lwjgl" too...
Offline bohdan

Junior Duke




Java-positive...


« Reply #22 - Posted 2006-03-25 03:30:08 »

Here is an interesting test, I think  Grin It is animated for convenience...

I have here 2 quads, Green and Blue. They are placed in OrderedGroup so that Green one supposed to be rendered on top of Blue one.

If you make them exactly the same size and exactly the same position the OrderedGroup is working perfectly!!!
If you want - change the order and you will get BLUE on top - working just as it is expected...

But!!! If you shift one just little bit or change its size  - look what funny efects you get here...   Shocked
Well..Ok, this efects are understood of course and not strange if to assume that OrderedGroup is not working under this conditions...

Use dX_BLUE as delta shift, and dSize_BLUE - as delta size...



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
import java.awt.Color;

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

import com.xith3d.render.CanvasPeer;
import com.xith3d.render.RenderPeer;
import com.xith3d.render.jsr231.RenderPeerImpl;
import com.xith3d.scenegraph.Appearance;
import com.xith3d.scenegraph.BranchGroup;
import com.xith3d.scenegraph.Canvas3D;
import com.xith3d.scenegraph.ColoringAttributes;
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);
        //------------------------------
        Appearance a1 = new Appearance();
        a1.setColoringAttributes(new ColoringAttributes(new Color3f(Color.GREEN),0));
        Appearance a2 = new Appearance();
        a2.setColoringAttributes(new ColoringAttributes(new Color3f(Color.BLUE),0));
       
        //======= adding OrderedGroup ===============
        float dX_BLUE    = 0;   // <<++ play here
        float dSize_BLUE = 0;   // <<++ or here
        //-------------------------------------------
        Shape3D quadGREEN = new Shape3D(TestUtils.
                  createPlane(0, 0, 0, 1, 1),a1);
        Shape3D quadBLUE = new Shape3D(TestUtils.
                  createPlane(dX_BLUE, 0, 0, 1f + dSize_BLUE, 1f + dSize_BLUE),a2);
        OrderedGroup ordGR = new OrderedGroup();
        //--- here play with order ------
        ordGR.addChild(quadGREEN);
        ordGR.addChild(quadBLUE);
        //-------------------------------
        scRootBG.addChild(ordGR);
        //======= running =============================
        frame.setVisible(true);
        Point3f camL = new Point3f(0,1.8f,1.8f);
        Point3f lookAtV = new Point3f();
        Vector3f upV = new Vector3f(0,0,1);
        float a = 0;
        long currTime = System.currentTimeMillis();
        long lastTime = currTime;
        while (frame.isVisible()) {
            scView.renderOnce();
            //--------------------
            currTime = System.currentTimeMillis();
            if (currTime - lastTime > 30) {
                lastTime = currTime;
                a += 0.03f;
                camL.z = (float)(1.8f*(Math.cos(a/2)));
                camL.x = (float)(1.8f*Math.sin(a));
                camL.y = (float)(1.8f*Math.cos(a));
                scView.getTransform().lookAt(camL,lookAtV,upV);
            }
            //--------------------
        }
        System.exit(0);
    }  
   
    public static void main(String args[]) {
        new OrderedGroupTest();
    }
}

Offline bohdan

Junior Duke




Java-positive...


« Reply #23 - Posted 2006-03-25 04:03:08 »

BTW, if you put Spheres instead of quads - exactly the same story apply... You can control order with no problems...

So basicaly, it seems like OrderedGroup/DecalGroup is working only when geometries of shapes are exactly coinciding! Then you really have control over rendering order!!!

Interesting.. what is the logic behind the OrderedGroup then? How it really works and why this condition (coinciding geometries) is necessary? Why it couldn't be applied just to any shapes?
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #24 - Posted 2006-03-25 09:16:16 »

yup that are exactly the results I'm getting.
If it would work like that consequently there would be no problem (from my side of view), but as I mentioned previously, transparency is also not handled correctly - With transparency I'm talking about alpha values of 0.5 and such. 0/1 transparency seems to work.

Actually if you want to specify the order of the rendering you could use the new MultipassView, but I think this might be a bit too overcomplicated.

:: JOODE :: Xith3d :: OdeJava ::
Offline bohdan

Junior Duke




Java-positive...


« Reply #25 - Posted 2006-03-25 12:36:41 »

If it would work like that consequently there would be no problem...

Well.. agree, but only regarding DecalGroup since the meaning of name "DecalGroup" assuming "decals" and everybody can expect certain conditions needs to be met.

But!!! "OrderedGroup" has too strong and general name to be limitted to this kind of behaviour. It either should be fixed to work for any shapes as it's name suggest, or need to be renamed to reflect the limitations!

Do you agree?
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #26 - Posted 2006-03-25 12:58:00 »

I agree.
And I'll look into the code.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Duke




Everything's possible, but not everything's fun...


« Reply #27 - Posted 2006-03-25 13:02:38 »

Well, I must learn a bit more about the renderers architecture before understanding where OrderedGroup is handled..
I'll see what I can do.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline arne

Senior Duke




money is the worst drug- we should not let it rule


« Reply #28 - Posted 2006-03-25 14:04:18 »

If it would work like that consequently there would be no problem...

Well.. agree, but only regarding DecalGroup since the meaning of name "DecalGroup" assuming "decals" and everybody can expect certain conditions needs to be met.

But!!! "OrderedGroup" has too strong and general name to be limitted to this kind of behaviour. It either should be fixed to work for any shapes as it's name suggest, or need to be renamed to reflect the limitations!

Do you agree?

I agree, too

:: JOODE :: Xith3d :: OdeJava ::
Offline bohdan

Junior Duke




Java-positive...


« Reply #29 - Posted 2006-03-26 02:57:30 »

Another interesting discovery  Huh

Actualy, if in those tests mentioned above you change OrderedGroup/DecalGroup to just Group - will make no difference at all!

This that the rendering order is controled by order in the group when Shapes' geometries coincide fully apply to "Group" too!!!  Wink
But this is actually understood, if geometries coincide no dicision can be maden by renderer who goes first so the order is just left intact, so we getting order as specified in the group and there is no magic!

In other worlds it seems that neither OrderedGroup neither DecalGroup is ever handled differently from just ordinary Group they extend...

Arne, you was saying you have some applications of OrderedGroup.. Can you try to change OrderedGroup to Group there and see if it makes any difference? I positive it will work just exactly the same way. Its seems they all three are just equivalent...  Undecided
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (35 views)
2014-10-17 03:59:02

Norakomi (26 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (76 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!