boxAlpha.setStartTime(Long.MAX_VALUE);
RotationInterpolator boxRotation = new RotationInterpolator(boxAlpha,tgmBox,
rotationAxis,0.0f,(float) Math.PI*2);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);
boxRotation.setSchedulingBounds(bounds);
//Add the rotation to the corresponding transform group.
tgmBox.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tgmBox.addChild(boxRotation);
//Create a transformgroup for the positioning of the box and add the
//transformgroup with the rotation.
Transform3D tfFBox = new Transform3D();
tfFBox.rotY(Math.PI/6);
Transform3D rotationX = new Transform3D();
rotationX.rotX(-Math.PI/5);
tfFBox.mul(rotationX);
TransformGroup tgFBox = new TransformGroup(tfFBox);
tgFBox.addChild(tgmBox);
//The same for the sphere:
Color3f ambientColourBSphere = new Color3f(0.0f,0.0f,0.0f);
Color3f emissiveColourBSphere = new Color3f(0.0f,0.0f,0.0f);
Color3f diffuseColourBSphere = new Color3f(0.0f,0.5f,0.0f);
Color3f specularColourBSphere = new Color3f(0.0f,0.8f,0.0f);
float shininessBSphere = 128.0f;
Appearance bSphereApp = new Appearance();
bSphereApp.setMaterial(new Material(ambientColourBSphere,
emissiveColourBSphere,
diffuseColourBSphere,
specularColourBSphere,
shininessBSphere));
Sphere bSphere = new Sphere(0.4f,bSphereApp);
bSphere.setUserData("sphere");
TransformGroup tgmBSphere = new TransformGroup();
tgmBSphere.addChild(bSphere);
//Create the transformation for shrinking.
Alpha sphereShrinkAlpha = new Alpha(1,2000);
sphereShrinkAlpha.setStartTime(Long.MAX_VALUE);
ScaleInterpolator shrinker = new ScaleInterpolator(sphereShrinkAlpha,
tgmBSphere,
new Transform3D(),
1.0f,0.5f);
shrinker.setSchedulingBounds(bounds);
tgmBSphere.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tgmBSphere.addChild(shrinker);
//Create the transformation for stretching the sphere again.
Alpha sphereStretchAlpha = new Alpha(1,2000);
sphereStretchAlpha.setStartTime(Long.MAX_VALUE);
ScaleInterpolator stretcher = new ScaleInterpolator(sphereStretchAlpha,
tgmBSphere,
new Transform3D(),
0.5f,1.0f);
stretcher.setSchedulingBounds(bounds);
tgmBSphere.addChild(stretcher);
//Create a transform group to position the sphere and add the
//transfromgroup with the shrinking/stretching.
Transform3D tfBSphere = new Transform3D();
tfBSphere.setTranslation(new Vector3f(2.0f,0.0f,-10.5f));
TransformGroup tgBSphere = new TransformGroup(tfBSphere);
tgBSphere.addChild(tgmBSphere);
//Create the root of the scene graph and add the box and the sphere group.
BranchGroup theScene = new BranchGroup();;
theScene.addChild(tgFBox);
theScene.addChild(tgBSphere);
//Define the data for the picking interaction and add the picking to the
//scene graph.
Alpha[] alphas = new Alpha[3];
alphas[0] = boxAlpha;
alphas[1] = sphereShrinkAlpha;
alphas[2] = sphereStretchAlpha;
BoundingSphere bs = new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);
return(theScene);
}