I am confused…perhaps youse guys can help…The code below is from a java3d terrain applet i once saw. He is setting up his floor terrain as a polygon array, roughly U shaped, and texturing with a grass image. What I don’t understand is the use of greater than 0 texture coord’s. I thought that these were required to range twixt 0 and 1 and yet this produces a nice ground floor. Any ideas what is happening here??
Appearance app = new Appearance();
app.setMaterial(new Material());
app.setTexture(texture);
TextureAttributes textureAttributes = new TextureAttributes();
textureAttributes.setTextureMode(TextureAttributes.MODULATE);
app.setTextureAttributes(textureAttributes);
// create geometry
GeometryInfo geom = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
Point3f[] coords = new Point3f[16];
coords[0] = new Point3f(-12.0f, 1.2f, -35.0f);
coords[1] = new Point3f(-12.0f, 1.0f, -18.0f);
coords[2] = new Point3f(-12.0f, 0.0f, -10.0f);
coords[3] = new Point3f(-12.0f, 0.0f, 0.0f);
coords[4] = new Point3f( -1.5f, 0.0f, 0.0f);
coords[5] = new Point3f( -0.5f, 0.0f, -10.0f);
coords[6] = new Point3f( -0.5f, 1.0f, -18.0f);
coords[7] = new Point3f(-0.25f, 1.0f, -30.0f);
coords[8] = new Point3f( 0.25f, 1.0f, -30.0f);
coords[9] = new Point3f( 0.5f, 1.0f, -18.0f);
coords[10] = new Point3f( 0.5f, 0.0f, -10.0f);
coords[11] = new Point3f( 1.5f, 0.0f, 0.0f);
coords[12] = new Point3f( 12.0f, 0.0f, 0.0f);
coords[13] = new Point3f( 12.0f, 0.0f, -10.0f);
coords[14] = new Point3f( 12.0f, 1.0f, -18.0f);
coords[15] = new Point3f( 12.0f, 1.2f, -35.0f);
geom.setCoordinates(coords);
Point2f[] text = new Point2f[16];
text[0] = new Point2f( -6.0f, -17.5f);
text[1] = new Point2f( -6.0f, -9.0f);
text[2] = new Point2f( -6.0f, -5.0f);
text[3] = new Point2f( -6.0f, 0.0f);
text[4] = new Point2f( -0.75f, 0.0f);
text[5] = new Point2f( -0.25f, -5.0f);
text[6] = new Point2f( -0.25f, -9.0f);
text[7] = new Point2f(-0.125f, -15.0f);
text[8] = new Point2f( 0.125f, -15.0f);
text[9] = new Point2f( 0.25f, -9.0f);
text[10] = new Point2f( 0.25f, -5.0f);
text[11] = new Point2f( 0.75f, 0.0f);
text[12] = new Point2f( 6.0f, 0.0f);
text[13] = new Point2f( 6.0f, -5.0f);
text[14] = new Point2f( 6.0f, -9.0f);
text[15] = new Point2f( 6.0f, -17.5f);
geom.setTextureCoordinates(text);
// there is only one polygon with 16 vertices
int[] stripCounts = new int[1];
stripCounts[0] = 16;
geom.setStripCounts(stripCounts);
// easy creation of other elements (normal, ...)
new Triangulator().triangulate(geom);
geom.recomputeIndices();
new NormalGenerator(Math.PI).generateNormals(geom);
geom.recomputeIndices();
new Stripifier().stripify(geom);
geom.recomputeIndices();
// create and return shape
Shape3D shape = new Shape3D(geom.getIndexedGeometryArray(), app);
return shape;