示例#1
0
  //
  //  Build scene
  //
  public Group buildScene() {
    // Get the current color
    Color3f color = (Color3f) colors[currentColor].value;
    float front = ((Float) fronts[currentFront].value).floatValue();
    float back = ((Float) backs[currentBack].value).floatValue();

    // Turn off the example headlight
    setHeadlightEnable(false);

    // Default to walk navigation
    setNavigationType(Walk);

    // Create the scene group
    Group scene = new Group();

    // BEGIN EXAMPLE TOPIC
    // Create influencing bounds
    BoundingSphere worldBounds =
        new BoundingSphere(
            new Point3d(0.0, 0.0, 0.0), // Center
            1000.0); // Extent

    // Set the fog color, front & back distances, and
    // its influencing bounds
    fog = new LinearFog();
    fog.setColor(color);
    fog.setFrontDistance(front);
    fog.setBackDistance(back);
    fog.setCapability(Fog.ALLOW_COLOR_WRITE);
    fog.setCapability(LinearFog.ALLOW_DISTANCE_WRITE);
    fog.setInfluencingBounds(worldBounds);
    scene.addChild(fog);
    // END EXAMPLE TOPIC

    // Set the background color and its application bounds
    //   Usually, the background color should match the fog color
    //   or the results look odd.
    background = new Background();
    background.setColor(color);
    background.setApplicationBounds(worldBounds);
    background.setCapability(Background.ALLOW_COLOR_WRITE);
    scene.addChild(background);

    // Build foreground geometry
    scene.addChild(new ColumnScene(this));

    return scene;
  }