public class TexturedPlane extends Shape3D {
private static Geometry createGeometry(List<Point3f> coordinates,
Vector3f normal) {
final int numberOfPoints = coordinates.size();
final QuadArray plane = new QuadArray(numberOfPoints,
GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2
| GeometryArray.NORMALS);
plane.setCoordinates(0, coordinates.toArray(new Point3f[] {}));
final TexCoord2f[] corners = { new TexCoord2f(0f, 0f),
new TexCoord2f(1f, 0f), new TexCoord2f(1f, 1f),
new TexCoord2f(0f, 1f) };
final TexCoord2f[] textureCoordinates = new TexCoord2f[numberOfPoints];
for (int i = 0; i < numberOfPoints; ++i) {
textureCoordinates[i] = new TexCoord2f(corners[i % 4]);
}
plane.setTextureCoordinates(0, 0, textureCoordinates);
for (int i = 0; i < numberOfPoints; ++i) {
plane.setNormal(i, normal);
}
return plane;
}