Example usage for javax.media.j3d Switch ALLOW_SWITCH_READ

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

Introduction

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

Prototype

int ALLOW_SWITCH_READ

To view the source code for javax.media.j3d Switch ALLOW_SWITCH_READ.

Click Source Link

Document

Specifies that this node allows reading its child selection and mask values and its current child.

Usage

From source file:LOD.java

public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    createLights(objRoot);// ww  w  .  j  a v a  2  s .  c o  m

    // Create the transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime. Add it to the
    // root of the subgraph.
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    objRoot.addChild(objTrans);

    // Create a switch to hold the different levels of detail
    Switch sw = new Switch(0);
    sw.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_READ);
    sw.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_WRITE);

    // Create several levels for the switch, with less detailed
    // spheres for the ones which will be used when the sphere is
    // further away
    sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 40));
    sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 20));
    sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 10));
    sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 3));

    // Add the switch to the main group
    objTrans.addChild(sw);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    // set up the DistanceLOD behavior
    float[] distances = new float[3];
    distances[0] = 5.0f;
    distances[1] = 10.0f;
    distances[2] = 25.0f;
    DistanceLOD lod = new DistanceLOD(distances);
    lod.addSwitch(sw);
    lod.setSchedulingBounds(bounds);
    objTrans.addChild(lod);

    // Have Java 3D perform optimizations on this scene graph.
    objRoot.compile();

    return objRoot;
}

From source file:Demo3D.java

/**
 * Create the subgraph #32//from w w w .j a  v a 2  s  .c  om
 * 
 * @return javax.media.j3d.TransformGroup trGr32_3 - the root of the
 *         subgraph #32
 */
public BranchGroup mySubGraph32() {
    // A BoundingSphere instance as general bounding region.
    boundsGen = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    // Create the first TransformGroup node trGr32_1 to:
    // 1) attach the Switch node with the five different earth's
    //    representations to the subgraph32
    // 2) attach a coordinate system to each earth's representation
    // 3) rotate each earth about its own y-axis.
    trGr32_1 = new TransformGroup();

    // With the ALLOW_TRANSFORM_WRITE capability, we allow the
    // modification of the TransformGroup's code by the behavior's
    // code at run time.
    trGr32_1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    // SwitchBehavior is the class which controls the fonctioning of
    // the switchEarths node.

    switchBehavior = new SwitchBehavior(this);
    switchBehavior.setSchedulingBounds(boundsGen);
    trGr32_1.addChild(switchBehavior);

    // The Switch which allows the rendering of the five different
    // earth's representations.
    switchEarths = new Switch();
    // With the ALLOW_TRANSFORM_WRITE, ALLOW_SWITCH_WRITE and
    // ALLOW_CHILDREN_READ
    // capabilities we allow to get or set new capabilities.
    switchEarths.setCapability(Switch.ALLOW_SWITCH_READ);
    switchEarths.setCapability(Switch.ALLOW_SWITCH_WRITE);
    switchEarths.setCapability(Switch.ALLOW_CHILDREN_READ);

    // Attach the different earth's representations to the Switch node.
    // Increasing
    earth_Points = new Earth("points", 0.4f);
    switchEarths.addChild(earth_Points.myEarth()); // # 0

    earth_Lines = new Earth("lines", 0.4f);
    switchEarths.addChild(earth_Lines.myEarth()); // # 1

    earth_Polygons = new Earth("polygons", 0.4f);
    switchEarths.addChild(earth_Polygons.myEarth()); // # 2

    earth_Gouraud = new Earth("gouraud", 0.4f);
    switchEarths.addChild(earth_Gouraud.myEarth()); // # 3

    earth_Texture = new Earth("texture", 0.4f);
    switchEarths.addChild(earth_Texture.myEarth()); // # 4

    // Decreasing
    switchEarths.addChild(earth_Texture.myEarth()); // # 4
    switchEarths.addChild(earth_Gouraud.myEarth()); // # 3
    switchEarths.addChild(earth_Polygons.myEarth()); // # 2
    switchEarths.addChild(earth_Lines.myEarth()); // # 1
    switchEarths.addChild(earth_Points.myEarth()); // # 0

    // Attach the Switch node with the five different earth's
    // representations to the TransformGroup node trGr32_1.
    trGr32_1.addChild(switchEarths);

    // Create and attach a coordinate system to the TransformGroup node
    // trGr32_1, that is to each earth's representation.
    coordSyst = new CoordSyst(1.0f, 1.0f, 0.0f, // Color of the x-axis
            0.0f, 0.0f, 1.0f, // Color of the y-axis
            1.0f, 0.0f, 0.0f, // Color of the z-axis
            0.6f); // Lenght of the 3 axes
    trGr32_1.addChild(coordSyst);

    // Create the alpha(t) function for the earth's rotation about
    // its own y-axis.
    rotationAlpha_1 = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 10000, 0, 0, 0, 0, 0);
    // Create the earth's rotation about its own y-axis.
    rotator_1 = new RotationInterpolator(rotationAlpha_1, trGr32_1, new Transform3D(), 0.0f,
            (float) Math.PI * 2.0f);
    rotator_1.setSchedulingBounds(boundsGen);
    trGr32_1.addChild(rotator_1);

    // Create a Transform3D instance to execute the desired "static
    // translation" of the earth, that is the rotation radius around
    // the sun.
    transl = new Transform3D();
    vectTransl = new Vector3d(2.5, 0.0, 0.0);
    transl.set(vectTransl);

    // Create the second TransformGroup node trGr32_2 and attach the
    // "static translation" transl to it.
    trGr32_2 = new TransformGroup(transl);

    // Attach the trGr32_1 node to the trGr32_2 node.
    trGr32_2.addChild(trGr32_1);

    // Create the third TransformGroup node trGr32_3 for the earth's
    // rotation around the sun.
    trGr32_3 = new TransformGroup();

    // With the ALLOW_TRANSFORM_WRITE capability, we allow the
    // modification of the TransformGroup's code by the behavior's
    // code at run time.
    trGr32_3.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    // Attach the trGr32_2 node to the trGr32_3 node.
    trGr32_3.addChild(trGr32_2);

    // Create the alpha(t) function for the earth's rotation around the sun.
    rotationAlpha_2 = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 20000, 0, 0, 0, 0, 0);

    // To restart correctly the rotation of the earth around the
    // sun after a detach/add process of the subgraph32 from the
    // BranchGroup node brGr3.
    rotationAlpha_2.setStartTime(System.currentTimeMillis());

    // Create the earth's rotation around the sun.
    rotator_2 = new RotationInterpolator(rotationAlpha_2, trGr32_3, new Transform3D(), 0.0f,
            (float) Math.PI * 2.0f);
    rotator_2.setSchedulingBounds(boundsGen);
    trGr32_3.addChild(rotator_2);

    // To allow the detaching of this subgraph32 from the
    // BranchGroup node brGr3.
    brGr32 = new BranchGroup();
    brGr32.setCapability(BranchGroup.ALLOW_DETACH);
    brGr32.addChild(trGr32_3);

    // Return the final version of the BranchGroup node brGr32.
    return brGr32;
}

From source file:TransformExplorer.java

CoordSys(float axisLength) {
    super(Switch.CHILD_ALL);

    float coordSysLength = axisLength;
    float labelOffset = axisLength / 20.0f;
    float axisRadius = axisLength / 500.0f;
    float arrowRadius = axisLength / 125.0f;
    float arrowHeight = axisLength / 50.0f;
    float tickRadius = axisLength / 125.0f;
    float tickHeight = axisLength / 250.0f;

    // Set the Switch to allow changes
    setCapability(Switch.ALLOW_SWITCH_READ);
    setCapability(Switch.ALLOW_SWITCH_WRITE);

    // Set up an appearance to make the Axis have
    // grey ambient, black emmissive, grey diffuse and grey specular
    // coloring./* ww w .j  a  v a  2  s.  c om*/
    //Material material = new Material(grey, black, grey, white, 64);
    Material material = new Material(white, black, white, white, 64);
    Appearance appearance = new Appearance();
    appearance.setMaterial(material);

    // Create a shared group to hold one axis of the coord sys
    SharedGroup coordAxisSG = new SharedGroup();

    // create a cylinder for the central line of the axis
    Cylinder cylinder = new Cylinder(axisRadius, coordSysLength, appearance);
    // cylinder goes from -coordSysLength/2 to coordSysLength in y
    coordAxisSG.addChild(cylinder);

    // create the shared arrowhead
    Cone arrowHead = new Cone(arrowRadius, arrowHeight, appearance);
    SharedGroup arrowHeadSG = new SharedGroup();
    arrowHeadSG.addChild(arrowHead);

    // Create a TransformGroup to move the arrowhead to the top of the
    // axis
    // The arrowhead goes from -arrowHeight/2 to arrowHeight/2 in y.
    // Put it at the top of the axis, coordSysLength / 2
    tmpVector.set(0.0f, coordSysLength / 2 + arrowHeight / 2, 0.0f);
    tmpTrans.set(tmpVector);
    TransformGroup topTG = new TransformGroup();
    topTG.setTransform(tmpTrans);
    topTG.addChild(new Link(arrowHeadSG));
    coordAxisSG.addChild(topTG);

    // create the minus arrowhead
    // Create a TransformGroup to turn the cone upside down:
    // Rotate 180 degrees around Z axis
    tmpAxisAngle.set(0.0f, 0.0f, 1.0f, (float) Math.toRadians(180));
    tmpTrans.set(tmpAxisAngle);

    // Put the arrowhead at the bottom of the axis
    tmpVector.set(0.0f, -coordSysLength / 2 - arrowHeight / 2, 0.0f);
    tmpTrans.setTranslation(tmpVector);
    TransformGroup bottomTG = new TransformGroup();
    bottomTG.setTransform(tmpTrans);
    bottomTG.addChild(new Link(arrowHeadSG));
    coordAxisSG.addChild(bottomTG);

    // Now add "ticks" at 1, 2, 3, etc.

    // create a shared group for the tick
    Cylinder tick = new Cylinder(tickRadius, tickHeight, appearance);
    SharedGroup tickSG = new SharedGroup();
    tickSG.addChild(tick);

    // transform each instance and add it to the coord axis group
    int maxTick = (int) (coordSysLength / 2);
    int minTick = -maxTick;
    for (int i = minTick; i <= maxTick; i++) {
        if (i == 0)
            continue; // no tick at 0

        // use a TransformGroup to offset to the tick location
        TransformGroup tickTG = new TransformGroup();
        tmpVector.set(0.0f, (float) i, 0.0f);
        tmpTrans.set(tmpVector);
        tickTG.setTransform(tmpTrans);
        // then link to an instance of the Tick shared group
        tickTG.addChild(new Link(tickSG));
        // add the TransformGroup to the coord axis
        coordAxisSG.addChild(tickTG);
    }

    // add a Link to the axis SharedGroup to the coordSys
    addChild(new Link(coordAxisSG)); // Y axis

    // Create TransformGroups for the X and Z axes
    TransformGroup xAxisTG = new TransformGroup();
    // rotate 90 degrees around Z axis
    tmpAxisAngle.set(0.0f, 0.0f, 1.0f, (float) Math.toRadians(90));
    tmpTrans.set(tmpAxisAngle);
    xAxisTG.setTransform(tmpTrans);
    xAxisTG.addChild(new Link(coordAxisSG));
    addChild(xAxisTG); // X axis

    TransformGroup zAxisTG = new TransformGroup();
    // rotate 90 degrees around X axis
    tmpAxisAngle.set(1.0f, 0.0f, 0.0f, (float) Math.toRadians(90));
    tmpTrans.set(tmpAxisAngle);
    zAxisTG.setTransform(tmpTrans);
    zAxisTG.addChild(new Link(coordAxisSG));
    addChild(zAxisTG); // Z axis

    // Add the labels. First we need a Font3D for the Text3Ds
    // select the default font, plain style, 0.5 tall. Use null for
    // the extrusion so we get "flat" text since we will be putting it
    // into an oriented Shape3D
    Font3D f3d = new Font3D(new Font("Default", Font.PLAIN, 1), null);

    // set up the +X label
    Text3D plusXText = new Text3D(f3d, "+X", origin, Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT);
    // orient around the local origin
    OrientedShape3D plusXTextShape = new OrientedShape3D(plusXText, appearance,
            OrientedShape3D.ROTATE_ABOUT_POINT, origin);
    // transform to scale down to 0.15 in height, locate at end of axis
    TransformGroup plusXTG = new TransformGroup();
    tmpVector.set(coordSysLength / 2 + labelOffset, 0.0f, 0.0f);
    tmpTrans.set(0.15f, tmpVector);
    plusXTG.setTransform(tmpTrans);
    plusXTG.addChild(plusXTextShape);
    addChild(plusXTG);

    // set up the -X label
    Text3D minusXText = new Text3D(f3d, "-X", origin, Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT);
    // orient around the local origin
    OrientedShape3D minusXTextShape = new OrientedShape3D(minusXText, appearance,
            OrientedShape3D.ROTATE_ABOUT_POINT, origin);
    // transform to scale down to 0.15 in height, locate at end of axis
    TransformGroup minusXTG = new TransformGroup();
    tmpVector.set(-coordSysLength / 2 - labelOffset, 0.0f, 0.0f);
    tmpTrans.set(0.15f, tmpVector);
    minusXTG.setTransform(tmpTrans);
    minusXTG.addChild(minusXTextShape);
    addChild(minusXTG);

    // set up the +Y label
    Text3D plusYText = new Text3D(f3d, "+Y", origin, Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT);
    // orient around the local origin
    OrientedShape3D plusYTextShape = new OrientedShape3D(plusYText, appearance,
            OrientedShape3D.ROTATE_ABOUT_POINT, origin);
    // transform to scale down to 0.15 in height, locate at end of axis
    TransformGroup plusYTG = new TransformGroup();
    tmpVector.set(0.0f, coordSysLength / 2 + labelOffset, 0.0f);
    tmpTrans.set(0.15f, tmpVector);
    plusYTG.setTransform(tmpTrans);
    plusYTG.addChild(plusYTextShape);
    addChild(plusYTG);

    // set up the -Y label
    Text3D minusYText = new Text3D(f3d, "-Y", origin, Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT);
    // orient around the local origin
    OrientedShape3D minusYTextShape = new OrientedShape3D(minusYText, appearance,
            OrientedShape3D.ROTATE_ABOUT_POINT, origin);
    // transform to scale down to 0.15 in height, locate at end of axis
    TransformGroup minusYTG = new TransformGroup();
    tmpVector.set(0.0f, -coordSysLength / 2 - labelOffset, 0.0f);
    tmpTrans.set(0.15f, tmpVector);
    minusYTG.setTransform(tmpTrans);
    minusYTG.addChild(minusYTextShape);
    addChild(minusYTG);

    // set up the +Z label
    Text3D plusZText = new Text3D(f3d, "+Z", origin, Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT);
    // orient around the local origin
    OrientedShape3D plusZTextShape = new OrientedShape3D(plusZText, appearance,
            OrientedShape3D.ROTATE_ABOUT_POINT, origin);
    // transform to scale down to 0.15 in height, locate at end of axis
    TransformGroup plusZTG = new TransformGroup();
    tmpVector.set(0.0f, 0.0f, coordSysLength / 2 + labelOffset);
    tmpTrans.set(0.15f, tmpVector);
    plusZTG.setTransform(tmpTrans);
    plusZTG.addChild(plusZTextShape);
    addChild(plusZTG);

    // set up the -Z label
    Text3D minusZText = new Text3D(f3d, "-Z", origin, Text3D.ALIGN_CENTER, Text3D.PATH_RIGHT);
    // orient around the local origin
    OrientedShape3D minusZTextShape = new OrientedShape3D(minusZText, appearance,
            OrientedShape3D.ROTATE_ABOUT_POINT, origin);
    // transform to scale down to 0.15 in height, locate at end of axis
    TransformGroup minusZTG = new TransformGroup();
    tmpVector.set(0.0f, 0.0f, -coordSysLength / 2 - labelOffset);
    tmpTrans.set(0.15f, tmpVector);
    minusZTG.setTransform(tmpTrans);
    minusZTG.addChild(minusZTextShape);
    addChild(minusZTG);
}

From source file:TransformExplorer.java

RotAxis(float axisLength) {
    super(Switch.CHILD_NONE);
    setCapability(Switch.ALLOW_SWITCH_READ);
    setCapability(Switch.ALLOW_SWITCH_WRITE);

    // set up the proportions for the arrow
    float axisRadius = axisLength / 120.0f;
    float arrowRadius = axisLength / 50.0f;
    float arrowHeight = axisLength / 30.0f;

    // create the TransformGroup which will be used to orient the axis
    axisTG = new TransformGroup();
    axisTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    axisTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    addChild(axisTG);/*  w ww  .  j a v a 2s.  co  m*/

    // Set up an appearance to make the Axis have 
    // blue ambient, black emmissive, blue diffuse and white specular 
    // coloring.  
    Material material = new Material(blue, black, blue, white, 64);
    Appearance appearance = new Appearance();
    appearance.setMaterial(material);

    // create a cylinder for the central line of the axis
    Cylinder cylinder = new Cylinder(axisRadius, axisLength, appearance);
    // cylinder goes from -length/2 to length/2 in y
    axisTG.addChild(cylinder);

    // create a SharedGroup for the arrowHead
    Cone arrowHead = new Cone(arrowRadius, arrowHeight, appearance);
    SharedGroup arrowHeadSG = new SharedGroup();
    arrowHeadSG.addChild(arrowHead);

    // Create a TransformGroup to move the cone to the top of the 
    // cylinder
    tmpVector.set(0.0f, axisLength / 2 + arrowHeight / 2, 0.0f);
    tmpTrans.set(tmpVector);
    TransformGroup topTG = new TransformGroup();
    topTG.setTransform(tmpTrans);
    topTG.addChild(new Link(arrowHeadSG));
    axisTG.addChild(topTG);

    // create the bottom of the arrow
    // Create a TransformGroup to move the cone to the bottom of the 
    // axis so that its pushes into the bottom of the cylinder
    tmpVector.set(0.0f, -(axisLength / 2), 0.0f);
    tmpTrans.set(tmpVector);
    TransformGroup bottomTG = new TransformGroup();
    bottomTG.setTransform(tmpTrans);
    bottomTG.addChild(new Link(arrowHeadSG));
    axisTG.addChild(bottomTG);

    updateAxisTransform();
}

From source file:FourByFour.java

public Positions() {

    // Define colors for lighting
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f red = new Color3f(0.9f, 0.1f, 0.2f);
    Color3f blue = new Color3f(0.3f, 0.3f, 0.8f);
    Color3f yellow = new Color3f(1.0f, 1.0f, 0.0f);
    Color3f ambRed = new Color3f(0.3f, 0.03f, 0.03f);
    Color3f ambBlue = new Color3f(0.03f, 0.03f, 0.3f);
    Color3f ambYellow = new Color3f(0.3f, 0.3f, 0.03f);
    Color3f ambWhite = new Color3f(0.3f, 0.3f, 0.3f);
    Color3f specular = new Color3f(1.0f, 1.0f, 1.0f);

    // Create the red appearance node
    redMat = new Material(ambRed, black, red, specular, 100.f);
    redMat.setLightingEnable(true);//from   ww w . j  a  v  a 2  s.c o  m
    redApp = new Appearance();
    redApp.setMaterial(redMat);

    // Create the blue appearance node
    blueMat = new Material(ambBlue, black, blue, specular, 100.f);
    blueMat.setLightingEnable(true);
    blueApp = new Appearance();
    blueApp.setMaterial(blueMat);

    // Create the yellow appearance node
    yellowMat = new Material(ambYellow, black, yellow, specular, 100.f);
    yellowMat.setLightingEnable(true);
    yellowApp = new Appearance();
    yellowApp.setMaterial(yellowMat);

    // Create the white appearance node
    whiteMat = new Material(ambWhite, black, white, specular, 100.f);
    whiteMat.setLightingEnable(true);
    whiteApp = new Appearance();
    whiteApp.setMaterial(whiteMat);

    // Load the point array with the offset (coordinates) for each of
    // the 64 positions.
    point = new Vector3f[64];
    int count = 0;
    for (int i = -30; i < 40; i += 20) {
        for (int j = -30; j < 40; j += 20) {
            for (int k = -30; k < 40; k += 20) {
                point[count] = new Vector3f((float) k, (float) j, (float) i);
                count++;
            }
        }
    }

    // Create the switch nodes
    posSwitch = new Switch(Switch.CHILD_MASK);
    humanSwitch = new Switch(Switch.CHILD_MASK);
    machineSwitch = new Switch(Switch.CHILD_MASK);

    // Set the capability bits
    posSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    posSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    humanSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    humanSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    machineSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    machineSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    // Create the bit masks
    posMask = new BitSet();
    humanMask = new BitSet();
    machineMask = new BitSet();

    // Create the small white spheres that mark unoccupied
    // positions.
    posSphere = new Sphere[64];
    for (int i = 0; i < 64; i++) {
        Transform3D transform3D = new Transform3D();
        transform3D.set(point[i]);
        TransformGroup transformGroup = new TransformGroup(transform3D);
        posSphere[i] = new Sphere(2.0f, Sphere.GENERATE_NORMALS | Sphere.ENABLE_APPEARANCE_MODIFY, 12,
                whiteApp);
        Shape3D shape = posSphere[i].getShape();
        ID id = new ID(i);
        shape.setUserData(id);
        transformGroup.addChild(posSphere[i]);
        posSwitch.addChild(transformGroup);
        posMask.set(i);
    }

    // Create the red spheres that mark the user's positions.
    for (int i = 0; i < 64; i++) {
        Transform3D transform3D = new Transform3D();
        transform3D.set(point[i]);
        TransformGroup transformGroup = new TransformGroup(transform3D);
        transformGroup.addChild(new Sphere(7.0f, redApp));
        humanSwitch.addChild(transformGroup);
        humanMask.clear(i);
    }

    // Create the blue cubes that mark the computer's positions.
    for (int i = 0; i < 64; i++) {
        Transform3D transform3D = new Transform3D();
        transform3D.set(point[i]);
        TransformGroup transformGroup = new TransformGroup(transform3D);
        BigCube cube = new BigCube(blueApp);
        transformGroup.addChild(cube.getChild());
        machineSwitch.addChild(transformGroup);
        machineMask.clear(i);
    }

    // Set the positions mask
    posSwitch.setChildMask(posMask);
    humanSwitch.setChildMask(humanMask);
    machineSwitch.setChildMask(machineMask);

    // Throw everything into a single group
    group = new Group();
    group.addChild(posSwitch);
    group.addChild(humanSwitch);
    group.addChild(machineSwitch);
}