Hi Duncan,
> I am displaying some trees on a terrain, using GIFs mapped to a
> rectangle (classic billboard situation.) I also have a rectangle
> attached to my ViewingPlatform, through which I view the scene ( a
> photograph has been mapped to the rectangle). Part of the program is to
> allow the user to toggle the transparency of the rectangle, so that the
> user can see the scene through the photo.
>
> This works fine when I initially set up the scene- however, as soon as
> the user begins toggling the transparency of the photograph (and I set
> the transparencyAttribute of the photograph), the transparent GIFs get
> rendered after the photograph, effectively placing them in front of the
> photo, when they are at least 300 units away from the ViewingPlatform.
> I assume this has something to do with the Z-order of semi-transparent
> objects- is there any known workaround?
The way Java 3D works is that it renders all of the non-transparent
objects first, then freezes the depth buffer, then renders all of the
semi-transparent objects. This is necessary to get the desired effects
for transparency. By default, the semi-transparent objects are not
rendered in any particular order.
However, when you want to order your rendering to get a desired depth
effect, which is often the case with semi-transparent objects, you can
place the semi-transparent objects under an OrderedGroup node and
render them in a particular order. In this case, it appears that you
want to render the rectangle attached to the view platform last.
Just one problem: If you are using SimpleUniverse, the view platform
geometry is in the view branch graph and the other geometry is in the
content branch graph -- and they share no nodes, only a Locale. How do
you get all of them under the same OrderedGroup Node? It would seem
that one solution is to build your own universe with a Locale that has
a BranchGroup as child and directly under it is a single OrderedGroup
child, which has two children. One child of the OrderedGroup is the
view branch graph and the other child is the content branch graph.
Render the content branch graph first and render the view branch graph
last -- thus rendering the platform geometry last.
As you mentioned, another solution to your problem is to replace the
transparent gifs under the billboards with regular geometry, so that
the only transparent object in the scene is your view platform
geometry. Then the depth buffer just takes care of everything
automatically.
Yet another approach would be to override postRender in Canvas3D and
render your platform geometry there. That method allows rendering to
the canvas after all of the scene graph rendering is done. However, it
is an immediate mode call, and might come with a performance penalty.
Also, it might not work with stereo.
Hope this helps.
Travis Bryson
Sun Microsystems
> Date: Sat, 13 Feb 1999 20:22:47 -0800
> From: Duncan Cavens <[EMAIL PROTECTED]>
> X-Accept-Language: en
> MIME-Version: 1.0
> To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> Subject: [java3d] Transparent GIFs and Transparency Attributes
> Content-Transfer-Encoding: 7bit
>
> I believe this was already briefly discussed in the list, but I was
> unable to find a solution mentioned.
>
> I am displaying some trees on a terrain, using GIFs mapped to a
> rectangle (classic billboard situation.) I also have a rectangle
> attached to my ViewingPlatform, through which I view the scene ( a
> photograph has been mapped to the rectangle). Part of the program is to
> allow the user to toggle the transparency of the rectangle, so that the
> user can see the scene through the photo.
>
> This works fine when I initially set up the scene- however, as soon as
> the user begins toggling the transparency of the photograph (and I set
> the transparencyAttribute of the photograph), the transparent GIFs get
> rendered after the photograph, effectively placing them in front of the
> photo, when they are at least 300 units away from the ViewingPlatform.
> I assume this has something to do with the Z-order of semi-transparent
> objects- is there any known workaround?
>
> I am considering replacing the trees mapped onto rectangles with a shape
> which has the same outline as the GIF (minus transparent areas), but
> would prefer not to have
> to add the complexity for that..
>
> Duncan.
>
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 3D Home Page: http://java.sun.com/products/java-media/3D/
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/