Howdy all,
   I've been combing the archives and reading through the FAQ to see if
there's anything that can help me.  Here's my problem:

  SUMMARY:
     It appears as if a 3d surface created using an IndexedTriangleArray,
renders the pieces of itself that should be obscured by other pieces of
itself, while correctly rendering pixels where there are interviening
objects.  I am using Windows2000 Java3d 1.2.1_04 Direct3d.  I've tried
moving to the latest Java3d beta, but my 3d surface isn't redered at all.


  DETAILS:
  I have developed a simple Map class that reads elevation data from a
file and creates a 3d surface via an IndexedTriangleArray.  I want to
create a MapOverlay, on top of the Map, which effectivly shades different
areas (effectively creating a "fog of war" so to speak).  The Map itself
often has a texture associated with it, so
I didn't want to develop a new texture to accomplish this.  Instead, what
I did, was to duplicate the Map's surface, and change the coloration so
that different areas of the map had different transparency values.  I
called this the MapOverlay.  So, a MapOverlay contains a seperate Map,
with the same elevation data but per vertex coloration that is diffent,
(and includes an non opaque alpha value.).  The MapOverlay is offset
from the original by 1 meter in the Z direction.  So the MapOverlay
is litterally on top of the Map.
Thrown into this mix is a Path
I've created using the Sphere primative, and an IndexedLineArray.  Both
the MapOverlay, and the MapPath are preceded by a Switch in the SceneGraph
so they can be completely "shut off".

My Scene Graph looks a little like this

                    BranchGroup
                        |
                  Transform Group
                        |
             |----------|----------|
             |          |          |
             |          |          |
           Map       Switch      Switch
                        |          |
                     MapOverlay  MapPath (the path I'm displaying)

An overhead View of just the Map looks like this:
http://www.corelore.org/~noah/problempictures/Overhead-NoOverlay-NoPath.jpg

Here your looking at the 3d terrain, colored by elevation.  The blue
represents 0 elevation, and the concentric squares represent two layered
pillars.

Adding in the Path makes the picture look like this:
http://www.corelore.org/~noah/problempictures/Overhead-NoOverlay-PathDisplayed.jpg
You can see that the path goes right over one of the pillars.

Adding the MapOverlay makes the picture look like this:
http://www.corelore.org/~noah/problempictures/Overhead-OverlayDisplayed-PathDisplayed.jpg
You can see that areas of "no interest" are heavily shaded, and areas of
interest are shaded less so.  The brightest segments, where the circles
overlap, represent areas whose alpha values are completely transparent.

This has all been rendered in ParellelProjection and directly
above the Map.  If we switch to PerspectiveProjection, and view the Map
from an ange we start to see "interesting results":

NOW THE PROBLEM OCCURS
http://www.corelore.org/~noah/problempictures/Oblique-OverlayFine-SolidDissapear1.jpg
Here you can see that although the MapOverlay is rendering properly (see
the "ghostly" pillar pieces), what's underneith is not.  The original Map
is drawing the wrong portions of itself.

Here, I've turned the MapOverlay off, and adjusted the viewing perspective
so that we are looking strait through one of the pillars of the Map.
http://www.corelore.org/~noah/problempictures/Oblique-NoOverlay-IndexedTriangleArrayTransparentToSelf.jpg
The first red arrow is pointing to a sphere located behind the pillar we
are viewing.  It appears as if the pixels in "front" of this sphere are
being rendered properly.  Notice that you can't see the pillars behind the
sphere and route.  The 2nd arrow is poinging to the pillars that should
not have been rendered.  They are located behind the foremost pillar.

The following is the code responsible for generating the appearance in
both of the maps.

/** Creates the appearance of the Map */
protected Appearance createAppearance() {
   Appearance retval = new Appearance(); //the appearance object to be returned
   Enumeration texels= null;            //used in theprocessing of the texturemap
   int index         = 0;  //used toindex Texture Coordinates into the Geometry

   //allow the capability to read and write to the appearance as a whole dynamically
   retval.setCapability(Appearance.ALLOW_TEXTURE_WRITE |
                        Appearance.ALLOW_TEXTURE_READ);

   //create a new material for the map
   Material mapMaterial = new Material();
   //add this material setting to the maps appearance
   retval.setMaterial(mapMaterial);

   //transparency handled by setTransparency()
   //set the transparency attributes
   TransparencyAttributes mapTA = new TransparencyAttributes();
   mapTA.setTransparencyMode(TransparencyAttributes.NICEST);
   retval.setTransparencyAttributes(mapTA);

   //obtain the initial overlays from the data source (texture)
   ImageOverlay[] overlays = mapDS.getOverlays();

   //Deal with the Polygon Attributes?
   PolygonAttributes myPA = new PolygonAttributes();
   myPA.setCullFace(myPA.CULL_BACK);
   retval.setPolygonAttributes(myPA);

   //Deal with the Rendering Attributes
   RenderingAttributes myRA = new RenderingAttributes();
   myRA.setDepthBufferEnable(true);
   myRA.setDepthBufferWriteEnable(true);
   retval.setRenderingAttributes(myRA);


   //dealing with the map texture (removed for bevity's sake)
   if (overlays != null) {              //if we have a valid
                //Texture code here
   }    //end if we have a valid ImageOverlay

   //return the adjusted appearance object to be used by the map
   return retval;
}

Note, that even though the regular Map has no Alpha values, I still set
its TransparencyAttributes.  If I only set the TransparencyAttribute for
the MapOverlay or if I set the Map's TA toTransparencyAttributes.NONE,
 the MapOverlay isn't rendered This is what happens:
http://www.corelore.org/~noah/problempictures/OverheadView-MapNoTA-OverlayDisplayed-PathDisplayed.jpg
Here's the MapOverlay *IS* on.

The Oblique view is more revealing...
http://www.corelore.org/~noah/problempictures/ObliqueView-MapNoTA-OverlayDisplayed-PathDisplayed.jpg
Here you can see lines that reveal the MapOverlay's existance, but the
whole MapOverlay isn't drawn right.  You'll notice, however, that the Map
*is* being drawn right.

I've tried using Java3d 1.3 Beta, and right out of the gate, neither my
Map or MapOverlay render at all.  They Java fly through didn't seem to
work either, so I didn't want to create significant changes in my code for
the Beta Releases sake.

Unfortunately, All of the code required to run this example is quite
large, but I have included links to the Map.java and MapOverlay.java
files.  You can see by the code that's been commented out, all the
different things I've tried to fix this problems.

I've tried to include as much helpful information as possible.  If you
have any requests or suggestions as to how I can make this clearly, just
let me know, and I will try.

ANY AND ALL HELP/INSIGHT/OBSERVATIONS ARE GREATLY APPRECIATED!


Noah J. Ternullo
Systems Engineer
Lockheed Martin Systems Integration

CODE LINKS:
http://www.corelore.org/~noah/problempictures/MapOverlay.java
http://www.corelore.org/~noah/problempictures/Map.java

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to