gi.setTextureCoordinates(0, texcoords);
NormalGenerator ng = new NormalGenerator();
ng.generateNormals(gi);
Stripifier st = new Stripifier();
st.stripify(gi);
geom[0] = gi.getGeometryArray();
// top
int[] strips = new int[scounts.size()];
for (int i = 0; i < strips.length; i++) {
strips[i] = scounts.elementAt(i).intValue();
}
count = new int[ccnt];
vertices = new double[total*3];
texcoords = new float[total*2];
float[] normals = new float[total*3];
voff = 0;
toff = 0;
int noff = 0;
for (int i = 0; i < ccnt; i++) {
Vector<int[]> contour = contours.elementAt(i);
count[i] = contour.size();
// reverse path to get front and back face right
for (int j = count[i]-1; j >= 0; j--) {
int[] v = contour.elementAt(j);
vertices[voff++] = v[0]/vw-vo;
vertices[voff++] = -v[1]/vh+vo;
vertices[voff++] = 0.5;
normals[noff++] = 0.0f;
normals[noff++] = 0.0f;
normals[noff++] = 1.0f;
texcoords[toff++] = v[0]/tw;
texcoords[toff++] = 1.0f-v[1]/th;
}
}
gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(vertices);
gi.setNormals(normals);
gi.setContourCounts(strips);
gi.setStripCounts(count);
gi.setTextureCoordinateParams(1, 2);
gi.setTextureCoordinates(0, texcoords);
st.stripify(gi);
geom[1] = gi.getIndexedGeometryArray(false);
voff = toff = noff = 0;
// bottom
for (int i = 0; i < ccnt; i++) {
Vector<int[]> contour = contours.elementAt(i);
count[i] = contour.size();
// don't reverse path to get front and back face right
for (int j = 0; j < count[i]; j++) {
int[] v = contour.elementAt(j);
vertices[voff++] = v[0]/vw-vo;
vertices[voff++] = -v[1]/vh+vo;
vertices[voff++] = -0.5;
normals[noff++] = 0.0f;
normals[noff++] = 0.0f;
normals[noff++] = -1.0f;
texcoords[toff++] = v[0]/tw;
texcoords[toff++] = 1.0f-v[1]/th;
}
}
gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
gi.setCoordinates(vertices);
gi.setNormals(normals);
gi.setContourCounts(strips);
gi.setStripCounts(count);
gi.setTextureCoordinateParams(1, 2);
gi.setTextureCoordinates(0, texcoords);
st.stripify(gi);
geom[2] = gi.getIndexedGeometryArray(false);
return geom;
}