> From: Duncan Cavens <[EMAIL PROTECTED]>
>
> I'm loading in about 10,000 triangles via the
> com.sun.j3d.utils.geometry.GeometryInfo class. I set up the
> GeometryInfo as a TRIANGLE_ARRAY, call setCoordinates(myArray).
>
> I then pass the Geometry Info through the NormalGenerator utility, and
> then create
> a Shape3D from the GeometryArray exposed on the GeometryInfo.
>
>
> when I try to use POLYGON_FILL, only every second triangle is displayed
> from any given direction. If I view the surface from the underneath,
> the _other_ half of the triangles appear to be displayed. I am using a
> single directional light source.
The problem is most likely the way you are specifying the triangles when you
load them. The order of the points in the triangle specifies orientation used
to generate the normal. The normal is defined as a vector perpendicular to the
front side of the triangle, so if you specify the points incorrectly J3D will
think the back of the triangle is really the front and generate a normal for the
wrong side of the polygon.
Here's how it works: on the "front" side of the triangle the points make a
counter-clockwise loop, on the "back" side they make a clockwise loop.
For example, given the triangle:
C---B
\ /
A
Specifying the points as A,B,C makes a counter-clockwise loop, so the triangle's
front is facing us. Specifying the points as A,C,B makes a clockwise loop and
the triangle's back is facing us.
I suspect that your original data has quads for each "grid" in an elevation map:
D--C
| /|
|/ |
A--B
If you split the quads as ABC and ACD then both triangles are front facing. If
you make the second triangle ADC then it will be back facing, leading to the
half-and-half display you are getting.
Hope this helps,
Doug Gehringer
Sun Microsystems
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/