|
How to use SwitchValueInterpolator |
|
|
The SwitchValueInterpolator doesnĄ¯t interpolate between values as other interpolators
do. It selects one of the children of a Switch object for rendering. The threshold
values for switching to a different child are determined by evenly dividing the 0.0
to 1.0 range by the number of children the Switch object has.
public BranchGroup createSceneGraph() {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup();
BoundingSphere bounds = new BoundingSphere();
// create target Switch with Capabilities
Switch objSwitch = new Switch();
objSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
// create Alpha
Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE
+ Alpha.DECREASING_ENABLE, 0, 0, 2000, 0, 1000, 2000, 0, 1000);
// create switch value interpolator
SwitchValueInterpolator swiInt = new SwitchValueInterpolator(alpha,
objSwitch);
swiInt.setSchedulingBounds(bounds);
swiInt.setLastChildIndex(2);// since switch made after interpolator
objRoot.addChild(swiInt);
// Add the Shapes
objSwitch.addChild(new Cylinder(0.4f,0.6f));
objSwitch.addChild(new Sphere(0.4f));
objSwitch.addChild(new Cone(0.4f,0.6f));
objRoot.addChild(objSwitch);
...
return objRoot;
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.