Building the Fractal Land
WrapFractalLand3D is like previous Wrap classes: it creates the 3D scene inside a JPanel. The createSceneGraph() method brings the various elements of the scene together:
void createSceneGraph(double flatness)
{
sceneBG = new BranchGroup();
bounds = new BoundingSphere(new Point3d(0,0,0), BOUNDSIZE);
lightScene(); // add the lights
addBackground(); // add the sky
// addFog(); // ade fog
// create the landscape: the floor and walls
land = new Landscape(flatness);
sceneBG.addChild( land.getLandBG() );
sceneBG.compile(); // fix the scene
}
lightScene() creates a single directional light, with no ambient backup, which makes the scene dark (and hopefully mysterious). The sky is set to be dark blue, which is the color used for the fog.
Linear Fog
The examples in Figure 26-1 use the createSceneGraph() method shown above, with the call to addFog() commented out. When uncommented, the scene looks something like Figure 26-3.

Figure 26-3. A foggy scene
The fog adds to the sinister nature of the landscape. I've commented it out in the example code to allow you to see what the entire landscape looks like.
The addFog() method is:
private void addFog()
{ LinearFog fogLinear = new LinearFog( skyColor, 15.0f, 30.0f);
fogLinear.setInfluencingBounds( bounds );
sceneBG.addChild( fogLinear );
}The LinearFog node makes the scene start to fade at 15.0f world units from the user and ...