Example usage for javax.media.j3d BoundingLeaf ALLOW_REGION_WRITE

List of usage examples for javax.media.j3d BoundingLeaf ALLOW_REGION_WRITE

Introduction

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

Prototype

int ALLOW_REGION_WRITE

To view the source code for javax.media.j3d BoundingLeaf ALLOW_REGION_WRITE.

Click Source Link

Document

Specifies that this BoundingLeaf node allows write access to its bounding region object.

Usage

From source file:ExLightBounds.java

public Group buildScene() {
    // Get the current bounding leaf position
    Point3f pos = (Point3f) positions[currentPosition].value;

    // Turn off the example headlight
    setHeadlightEnable(false);//  w w w.  j ava 2 s.  c  o m

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

    // BEGIN EXAMPLE TOPIC
    // Create a bounding leaf we'll use or not use depending
    // upon menu selections. Put it within a transform group
    // so that we can move the leaf about.
    leafTransformGroup = new TransformGroup();
    leafTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    Transform3D tr = new Transform3D();
    tr.setTranslation(new Vector3f(pos));
    leafTransformGroup.setTransform(tr);

    leafBounds = new BoundingLeaf(worldBounds);
    leafBounds.setCapability(BoundingLeaf.ALLOW_REGION_WRITE);
    leafTransformGroup.addChild(leafBounds);
    scene.addChild(leafTransformGroup);

    // Add a directional light whose bounds we'll modify
    // Set its color and aim direction
    light = new DirectionalLight();
    light.setEnable(true);
    light.setColor(White);
    light.setDirection(new Vector3f(1.0f, 0.0f, -1.0f));
    light.setCapability(DirectionalLight.ALLOW_INFLUENCING_BOUNDS_WRITE);

    // Set the bounds to be either from the leaf or from
    // explicit bounds, depending upon the menu initial state
    if (boundingLeafOnOff)
        // Use bounding leaf
        light.setInfluencingBoundingLeaf(leafBounds);
    else
        // Use bounds on the light
        light.setInfluencingBounds(worldBounds);

    // Set the scope list to include nothing initially.
    // This defaults to "universal scope" which covers
    // everything.

    scene.addChild(light);

    // Add an ambient light to dimly illuminate the rest of
    // the shapes in the scene to help illustrate that the
    // directional light is being bounded... otherwise it looks
    // like we're just removing shapes from the scene
    AmbientLight ambient = new AmbientLight();
    ambient.setEnable(true);
    ambient.setColor(White);
    ambient.setInfluencingBounds(worldBounds);
    scene.addChild(ambient);
    // END EXAMPLE TOPIC

    // Build foreground geometry
    scene.addChild(new SphereGroup());

    return scene;
}

From source file:AlternateAppearanceBoundsTest.java

BranchGroup createSceneGraph() {
    BranchGroup objRoot = new BranchGroup();

    // Create an alternate appearance
    otherApp = new Appearance();
    altMat = new Material();
    altMat.setCapability(Material.ALLOW_COMPONENT_WRITE);
    altMat.setDiffuseColor(new Color3f(0.0f, 1.0f, 0.0f));
    otherApp.setMaterial(altMat);//w  w w.j a v a 2 s .c om

    altApp = new AlternateAppearance();
    altApp.setAppearance(otherApp);
    altApp.setCapability(AlternateAppearance.ALLOW_BOUNDS_WRITE);
    altApp.setCapability(AlternateAppearance.ALLOW_INFLUENCING_BOUNDS_WRITE);
    altApp.setInfluencingBounds(worldBounds);
    objRoot.addChild(altApp);

    // Build foreground geometry
    Appearance app1 = new Appearance();
    mat1 = new Material();
    mat1.setCapability(Material.ALLOW_COMPONENT_WRITE);
    mat1.setDiffuseColor(new Color3f(1.0f, 0.0f, 0.0f));
    app1.setMaterial(mat1);
    content1 = new SphereGroup(0.05f, // radius of spheres
            0.15f, // x spacing
            0.15f, // y spacing
            5, // number of spheres in X
            5, // number of spheres in Y
            app1, // appearance
            true); // alt app override = true
    objRoot.addChild(content1);
    shapes1 = ((SphereGroup) content1).getShapes();

    // Add lights
    light1 = new DirectionalLight();
    light1.setEnable(true);
    light1.setColor(new Color3f(0.2f, 0.2f, 0.2f));
    light1.setDirection(new Vector3f(1.0f, 0.0f, -1.0f));
    light1.setInfluencingBounds(worldBounds);
    light1.setCapability(DirectionalLight.ALLOW_INFLUENCING_BOUNDS_WRITE);
    light1.setCapability(DirectionalLight.ALLOW_BOUNDS_WRITE);
    objRoot.addChild(light1);

    // Add an ambient light to dimly illuminate the rest of
    // the shapes in the scene to help illustrate that the
    // directional lights are being scoped... otherwise it looks
    // like we're just removing shapes from the scene
    AmbientLight ambient = new AmbientLight();
    ambient.setEnable(true);
    ambient.setColor(new Color3f(1.0f, 1.0f, 1.0f));
    ambient.setInfluencingBounds(worldBounds);
    objRoot.addChild(ambient);

    // Define a bounding leaf
    leafBounds = new BoundingLeaf(allBounds[currentBounds]);
    leafBounds.setCapability(BoundingLeaf.ALLOW_REGION_WRITE);
    objRoot.addChild(leafBounds);
    if (boundingLeafOn) {
        altApp.setInfluencingBoundingLeaf(leafBounds);
    } else {
        altApp.setInfluencingBounds(allBounds[currentBounds]);
    }

    return objRoot;
}