I'm attempting to load in a lake to Java3d using the GeometryInfo
utility.. I have a series of points which define the outer edges of the
lake, and am loading them in as a POLYGON_ARRAY, with only a single
contour..
It works fine, except that when I pass it into the Triangulator, the
normals always face the wrong way (down).. And when I set the
PolygonAttributes to CULL_NONE, the upwards view is all screwed up.
I've tried manually setting the normals to (0,0,1), but nothing
changes. I've also tried switching the order of the points, so that
I've tried both counterclockwise and clockwise, but nothing had any
impact at all.. Any ideas?
Duncan.
gi=new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
//Create an Array the Same Size as the Point List
Point3d[] p=new Point3d[thePoints.size()];
//Copy the Points from the List into the Array (used so I can switch the
order of the points)
for (int i=0;i<thePoints.size();i++){
//(int i=thePoints.size()-1;i>-1;i--) {
p[i]=(Point3d) thePoints.get(i);
p[i].z=p[i].z+2;
}
gi.setCoordinates(p);
int[] ii={thePoints.size()};
gi.setStripCounts( ii);
Triangulator tri=new Triangulator();
tri.triangulate(gi);
NormalGenerator ng=new NormalGenerator();
ng.generateNormals(gi);
Vector3f[] normals=gi.getNormals();
for (int i=0;i<normals.length;i++){
normals[i]=new Vector3f(0,0,1);
}
gi.setNormals(normals);
Appearance app=new Appearance();
// Set up the polygon attributes
PolygonAttributes pa = new PolygonAttributes();
pa.setCullFace(pa.CULL_NONE);
app.setPolygonAttributes(pa);
Shape3D s=new Shape3D(gi.getGeometryArray(),app);
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/