Example usage for javax.media.j3d Switch setChildMask

List of usage examples for javax.media.j3d Switch setChildMask

Introduction

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

Prototype

public void setChildMask(BitSet childMask) 

Source Link

Document

Sets the child selection mask.

Usage

From source file:SwitchTest.java

protected BranchGroup createSceneBranchGroup() {
    BranchGroup objRoot = super.createSceneBranchGroup();

    double labelScale = 20;

    // flip this boolean to either display all
    // the child nodes or to just display the 3, 6 and 7th.
    final boolean bDisplayAll = false;

    // create the Switch Node
    int nMode = Switch.CHILD_ALL;

    if (bDisplayAll == false)
        nMode = Switch.CHILD_MASK;//from   w w  w .j  a va 2  s.c  o  m

    Switch switchGroup = new Switch(nMode);
    switchGroup.setCapability(Switch.ALLOW_SWITCH_WRITE);

    switchGroup.addChild(createLabel("Child Node 1", labelScale));
    switchGroup.addChild(createLabel("Child Node 2", labelScale));
    switchGroup.addChild(createLabel("Child Node 3", labelScale));
    switchGroup.addChild(createLabel("Child Node 4", labelScale));
    switchGroup.addChild(createLabel("Child Node 5", labelScale));
    switchGroup.addChild(createLabel("Child Node 6", labelScale));
    switchGroup.addChild(createLabel("Child Node 7", labelScale));

    if (bDisplayAll == false) {
        java.util.BitSet visibleNodes = new java.util.BitSet(switchGroup.numChildren());

        // make the third, sixth and seventh nodes visible
        visibleNodes.set(2);
        visibleNodes.set(5);
        visibleNodes.set(6);

        switchGroup.setChildMask(visibleNodes);
    }

    // finally add the Switch Node
    objRoot.addChild(switchGroup);

    return objRoot;
}