Example usage for javax.media.j3d DistanceLOD DistanceLOD

List of usage examples for javax.media.j3d DistanceLOD DistanceLOD

Introduction

In this page you can find the example usage for javax.media.j3d DistanceLOD DistanceLOD.

Prototype

public DistanceLOD(float[] distances, Point3f position) 

Source Link

Document

Constructs and initializes a DistanceLOD node with the specified array of distances and the specified position.

Usage

From source file:SimpleLOD.java

/**
 * Build the content branch for the scene graph This creates three
 * cylinders, each with a different resolution. These are then used with a
 * LOD node to implement a crude level of detail.
 * //  w  ww .j a  v a 2s  . c  o m
 * @return BranchGroup that is the root of the content
 */
protected BranchGroup buildContentBranch() {
    //Create the appearance
    Appearance app = new Appearance();
    Color3f ambientColour = new Color3f(1.0f, 1.0f, 0.0f);
    Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f diffuseColour = new Color3f(1.0f, 1.0f, 0.0f);
    float shininess = 20.0f;
    app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess));
    //Make the switch node that is to used with the LOD
    //and make it writable
    Switch LODswitch = new Switch();
    LODswitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
    //Add the three cylinders
    LODswitch.addChild(new Cylinder(1.0f, 1.0f, Cylinder.GENERATE_NORMALS, 10, 10, app));
    LODswitch.addChild(new Cylinder(1.0f, 1.0f, Cylinder.GENERATE_NORMALS, 5, 5, app));
    LODswitch.addChild(new Cylinder(1.0f, 1.0f, Cylinder.GENERATE_NORMALS, 3, 3, app));
    //Define the distances for the LOD
    float[] LODdistances = { 5.0f, 10.0f, 15.0f };
    DistanceLOD myLOD = new DistanceLOD(LODdistances, new Point3f(0.0f, 0.0f, 0.0f));
    myLOD.setSchedulingBounds(bounds);
    //Add the switch to the LOD
    myLOD.addSwitch(LODswitch);
    BranchGroup contentBranch = new BranchGroup();
    contentBranch.addChild(myLOD);
    addLights(contentBranch);

    contentBranch.addChild(LODswitch);
    return contentBranch;

}