bohdan
Junior Member  
Java-positive...
|
 |
«
Posted
2006-03-15 23: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...  Is there anything specific about OrderedGroup? Will appreciate your help... Bohdan.
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #1 - Posted
2006-03-16 18: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"
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #2 - Posted
2006-03-16 20: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!
|
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #4 - Posted
2006-03-17 07: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...
|
|
|
|
Amos Wenger
|
 |
«
Reply #5 - Posted
2006-03-17 17: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"
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #6 - Posted
2006-03-17 17:22:12 » |
|
yep - full hit.
|
|
|
|
Amos Wenger
|
 |
«
Reply #7 - Posted
2006-03-17 17:29:04 » |
|
 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"
|
|
|
Yuri Vl. Gushchin
Senior Member   
Speak Java!
|
 |
«
Reply #8 - Posted
2006-03-23 10:40:01 » |
|
Hi, 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
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #9 - Posted
2006-03-23 17: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!
|
|
Amos Wenger
|
 |
«
Reply #10 - Posted
2006-03-23 18: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"
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #11 - Posted
2006-03-24 01: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..
|
|
|
|
|
Yuri Vl. Gushchin
Senior Member   
Speak Java!
|
 |
«
Reply #12 - Posted
2006-03-24 09: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
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #13 - Posted
2006-03-24 17:54:25 » |
|
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.
|
|
|
|
Amos Wenger
|
 |
«
Reply #14 - Posted
2006-03-24 18:23:07 » |
|
|
"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #15 - Posted
2006-03-24 20: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); 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)); Shape3D cube = new Shape3D(TestUtils.createCubeViaTriangles(0, 0, 0, 1.5f, true)); Shape3D sphere = new Shape3D(TestUtils.createSphere(1f, 16)); OrderedGroup ordGR = new OrderedGroup(); ordGR.addChild(cube); ordGR.addChild(sphere); scRootBG.addChild(ordGR); 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.
|
|
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #16 - Posted
2006-03-24 21:53:22 » |
|
mmh I only tested, when the different shapes were at exactly the same location (and I already had problems with that)
|
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #17 - Posted
2006-03-24 22: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)
|
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #18 - Posted
2006-03-24 22:27:02 » |
|
I was able to validate your results with my test case, too. Seems I just had luck 
|
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #19 - Posted
2006-03-24 22: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?
|
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #20 - Posted
2006-03-24 22:55:45 » |
|
Thanks Arne, for helping!
Yes, I actually originally tested it on jsr231...
|
|
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #21 - Posted
2006-03-24 23:34:07 » |
|
No go on "lwjgl" too...
|
|
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #22 - Posted
2006-03-25 04:30:08 » |
|
Here is an interesting test, I think  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...  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); 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)); float dX_BLUE = 0; float dSize_BLUE = 0; 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(); ordGR.addChild(quadGREEN); ordGR.addChild(quadBLUE); scRootBG.addChild(ordGR); 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(); } } |
|
|
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #23 - Posted
2006-03-25 05: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?
|
|
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #24 - Posted
2006-03-25 10: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.
|
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #25 - Posted
2006-03-25 13: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?
|
|
|
|
|
Amos Wenger
|
 |
«
Reply #26 - Posted
2006-03-25 13: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"
|
|
|
Amos Wenger
|
 |
«
Reply #27 - Posted
2006-03-25 14: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"
|
|
|
arne
Senior Member   
money is the worst drug- we should not let it rule
|
 |
«
Reply #28 - Posted
2006-03-25 15: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
|
|
|
|
bohdan
Junior Member  
Java-positive...
|
 |
«
Reply #29 - Posted
2006-03-26 04:57:30 » |
|
Another interesting discovery 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!!! 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... 
|
|
|
|
|
|