coords [j++] = bottom [0];
coords [j++] = top [0];
coords [j++] = top [points.length - 1];
}
GeometryInfo geometryInfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
geometryInfo.setCoordinates (coords);
// Compute wall texture coordinates
if (texture != null) {
float halfThicknessSq = (wall.getThickness() * wall.getThickness()) / 4;
TexCoord2f [] textureCoords = new TexCoord2f [rectanglesCount * 4];
float yMinTextureCoords = yMin / texture.getHeight();
TexCoord2f firstTextureCoords = new TexCoord2f(0, yMinTextureCoords);
j = 0;
// Tolerate more error with round walls since arc points are approximative
float epsilon = arcCircleCenter == null
? 0.0001f
: halfThicknessSq / 4;
for (int index = 0; index < points.length; index++) {
int nextIndex = (index + 1) % points.length;
if (usedRectangle [index]) {
if (Math.abs(distanceSqToWallMiddle [index] - halfThicknessSq) < epsilon
&& Math.abs(distanceSqToWallMiddle [nextIndex] - halfThicknessSq) < epsilon) {
// Compute texture coordinates of wall part parallel to wall middle
// according to textureReferencePoint
float firstHorizontalTextureCoords;
float secondHorizontalTextureCoords;
if (arcCircleCenter == null) {
firstHorizontalTextureCoords = (float)Point2D.distance(textureReferencePoint[0], textureReferencePoint[1],
points [index][0], points [index][1]) / texture.getWidth();
secondHorizontalTextureCoords = (float)Point2D.distance(textureReferencePoint[0], textureReferencePoint[1],
points [nextIndex][0], points [nextIndex][1]) / texture.getWidth();
} else {
if (pointUCoordinates [index] == null) {
float pointAngle = (float)Math.atan2(points [index][1] - arcCircleCenter [1], points [index][0] - arcCircleCenter [0]);
pointAngle = adjustAngleOnReferencePointAngle(pointAngle, referencePointAngle, arcExtent);
pointUCoordinates [index] = (pointAngle - referencePointAngle) * arcCircleRadius / texture.getWidth();
}
if (pointUCoordinates [nextIndex] == null) {
float pointAngle = (float)Math.atan2(points [nextIndex][1] - arcCircleCenter [1], points [nextIndex][0] - arcCircleCenter [0]);
pointAngle = adjustAngleOnReferencePointAngle(pointAngle, referencePointAngle, arcExtent);
pointUCoordinates [nextIndex] = (pointAngle - referencePointAngle) * arcCircleRadius / texture.getWidth();
}
firstHorizontalTextureCoords = pointUCoordinates [index];
secondHorizontalTextureCoords = pointUCoordinates [nextIndex];
}
textureCoords [j++] = new TexCoord2f(firstHorizontalTextureCoords, yMinTextureCoords);
textureCoords [j++] = new TexCoord2f(secondHorizontalTextureCoords, yMinTextureCoords);
textureCoords [j++] = new TexCoord2f(secondHorizontalTextureCoords, top [nextIndex].y / texture.getHeight());
textureCoords [j++] = new TexCoord2f(firstHorizontalTextureCoords, top [index].y / texture.getHeight());
} else {
float horizontalTextureCoords = (float)Point2D.distance(points [index][0], points [index][1],
points [nextIndex][0], points [nextIndex][1]) / texture.getWidth();
textureCoords [j++] = firstTextureCoords;
textureCoords [j++] = new TexCoord2f(horizontalTextureCoords, yMinTextureCoords);
textureCoords [j++] = new TexCoord2f(horizontalTextureCoords, top [nextIndex].y / texture.getHeight());
textureCoords [j++] = new TexCoord2f(0, top [index].y / texture.getHeight());
}
}
}
geometryInfo.setTextureCoordinateParams(1, 2);
geometryInfo.setTextureCoordinates(0, textureCoords);
}
// Generate normals
NormalGenerator normalGenerator = new NormalGenerator();
if (arcCircleCenter == null) {
normalGenerator.setCreaseAngle(0);
}
normalGenerator.generateNormals(geometryInfo);
return geometryInfo.getIndexedGeometryArray();
}