/**
* Updates ground coloring and texture attributes from home ground color and texture.
*/
private void update(boolean waitTextureLoadingEnd) {
Home home = (Home)getUserData();
Shape3D groundShape = (Shape3D)getChild(0);
int currentGeometriesCount = groundShape.numGeometries();
Color3f groundColor = new Color3f(new Color(home.getEnvironment().getGroundColor()));
final Appearance groundAppearance = groundShape.getAppearance();
groundAppearance.getColoringAttributes().setColor(groundColor);
HomeTexture groundTexture = home.getEnvironment().getGroundTexture();
if (groundTexture != null) {
final TextureManager imageManager = TextureManager.getInstance();
imageManager.loadTexture(groundTexture.getImage(), waitTextureLoadingEnd,
new TextureManager.TextureObserver() {
public void textureUpdated(Texture texture) {
groundAppearance.setTexture(texture);
}
});
} else {
groundAppearance.setTexture(null);
}
// Create ground geometry
List<Point3f> coords = new ArrayList<Point3f>();
List<Integer> stripCounts = new ArrayList<Integer>();
// First add the coordinates of the ground rectangle
coords.add(new Point3f(this.originX, 0, this.originY));
coords.add(new Point3f(this.originX, 0, this.originY + this.depth));
coords.add(new Point3f(this.originX + this.width, 0, this.originY + this.depth));
coords.add(new Point3f(this.originX + this.width, 0, this.originY));
// Compute ground texture coordinates if necessary
List<TexCoord2f> textureCoords = new ArrayList<TexCoord2f>();
if (groundTexture != null) {
textureCoords.add(new TexCoord2f(0, 0));
textureCoords.add(new TexCoord2f(0, -this.depth / groundTexture.getHeight()));
textureCoords.add(new TexCoord2f(this.width / groundTexture.getWidth(), -this.depth / groundTexture.getHeight()));
textureCoords.add(new TexCoord2f(this.width / groundTexture.getWidth(), 0));
}
stripCounts.add(4);
// Compute the union of the rooms
Area roomsArea = new Area();
for (Room room : home.getRooms()) {
if (room.isFloorVisible()) {
float [][] points = room.getPoints();
if (points.length > 2) {
roomsArea.add(new Area(getShape(points)));
}