Example usage for javax.media.j3d SwitchValueInterpolator setEnable

List of usage examples for javax.media.j3d SwitchValueInterpolator setEnable

Introduction

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

Prototype

public void setEnable(boolean state) 

Source Link

Document

Enables or disables this Behavior.

Usage

From source file:PointTest.java

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

    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 14000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f,
            (float) Math.PI * 2.0f);
    rotator.setSchedulingBounds(getApplicationBounds());
    objTrans.addChild(rotator);//from  w w  w.j av a 2  s . c  o  m

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

    switchGroup.addChild(createPoints(1, 5, false));
    switchGroup.addChild(createPoints(1, 5, true));
    switchGroup.addChild(createPoints(8, 10, false));
    switchGroup.addChild(createPoints(8, 10, true));

    switchGroup.addChild(createPoints(2, 5, false));
    switchGroup.addChild(createPoints(2, 5, true));
    switchGroup.addChild(createPoints(2, 20, false));
    switchGroup.addChild(createPoints(2, 20, true));

    // create a SwitchValueInterpolator to
    // cycle through the child nodes in the Switch Node
    Alpha switchAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 15000, 0, 0, 0, 0, 0);

    SwitchValueInterpolator switchInterpolator = new SwitchValueInterpolator(switchAlpha, switchGroup);
    switchInterpolator.setSchedulingBounds(getApplicationBounds());
    switchInterpolator.setEnable(true);

    // WARNING: do not add the SwitchValueInterpolator to the Switch Node!
    objRoot.addChild(switchInterpolator);

    objTrans.addChild(switchGroup);
    objRoot.addChild(objTrans);

    return objRoot;
}

From source file:NodesTest.java

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

    double labelScale = 20;

    // create the top level Switch Node
    // we will use the Switch Node to switch the
    // other Nodes on and off.
    // 1: Switch/*  w  w w .ja va  2s.  c  o  m*/
    Switch switchGroup = new Switch();
    switchGroup.setCapability(Switch.ALLOW_SWITCH_WRITE);
    switchGroup.addChild(createLabel("1. Switch Label", labelScale));

    // 2: BranchGroup
    BranchGroup branchGroup = new BranchGroup();
    branchGroup.addChild(createLabel("2. BranchGroup", labelScale));
    switchGroup.addChild(branchGroup);

    // 3: OrderedGroup,
    OrderedGroup orderedGroup = new OrderedGroup();
    orderedGroup.addChild(createLabel("3. OrderedGroup", labelScale));
    orderedGroup.addChild(createLabel("Child 1", labelScale));
    orderedGroup.addChild(createLabel("Child 2", labelScale));
    switchGroup.addChild(orderedGroup);

    // 4: SharedGroup,
    SharedGroup sharedGroup1 = new SharedGroup();
    sharedGroup1.addChild(createLabel("4. Shared Group 1", labelScale));
    switchGroup.addChild(new Link(sharedGroup1));

    // 5: Primitive,
    BranchGroup primitiveGroup = new BranchGroup();
    primitiveGroup.addChild(createLabel("5. Primitive", labelScale));
    primitiveGroup.addChild(new Sphere(2));
    switchGroup.addChild(primitiveGroup);

    // 6: TransformGroup
    TransformGroup transformGroup = new TransformGroup();
    transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, transformGroup, yAxis, 0.0f,
            (float) Math.PI * 2.0f);
    rotator.setSchedulingBounds(createApplicationBounds());
    transformGroup.addChild(rotator);

    transformGroup.addChild(new ColorCube(2));
    transformGroup.addChild(createLabel("6. TransformGroup", labelScale));
    switchGroup.addChild(transformGroup);

    // 7: add another copy of the shared group
    switchGroup.addChild(new Link(sharedGroup1));

    // create a SwitchValueInterpolator to
    // cycle through the child nodes in the Switch Node
    Alpha switchAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 10000, 0, 0, 0, 0, 0);

    SwitchValueInterpolator switchInterpolator = new SwitchValueInterpolator(switchAlpha, switchGroup);
    switchInterpolator.setSchedulingBounds(createApplicationBounds());
    switchInterpolator.setEnable(true);

    // WARNING: do not add the SwitchValueInterpolator to the Switch Node!
    objRoot.addChild(switchInterpolator);

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

    return objRoot;
}