import java.applet.Applet;
import java.awt.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class RotationTest extends Applet {
   
   public static void main (String[] args) {
      Frame frame = new MainFrame(new RotationTest(), 400, 400);
   }
   
   public RotationTest() {
      setLayout(new BorderLayout());
      Canvas3D c3d = new Canvas3D(null);
      add("Center", c3d);
      SimpleUniverse su = new SimpleUniverse(c3d);  
      
      BranchGroup scene = createSceneGraph(su);
      
      su.getViewingPlatform().setNominalViewingTransform();
      
      su.addBranchGraph(scene);
   }
   
   private BranchGroup createSceneGraph(SimpleUniverse su) {
      
      BranchGroup objRoot = new BranchGroup();
      
      ColorCube cube = new ColorCube(0.4);
      
      Transform3D rot = new Transform3D();
      rot.rotZ(Math.PI/5.0d);
      
      TransformGroup objSpin = new TransformGroup();
      objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
      
      Alpha rotation = new Alpha(-1, 4000);
      
      objSpin.addChild(cube);
      
      RotationInterpolator rotator = new RotationInterpolator(rotation, objSpin, rot, 0.0f, (float) Math.PI * 2.0f);
      rotator.setSchedulingBounds(new BoundingSphere());
      objSpin.addChild(rotator);
      objRoot.addChild(objSpin);
      return objRoot;
   } 
}
