import java.applet.Applet;
import java.awt.BorderLayout;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
//Bare minimum really boring cube.
// Shows bare bones Universe creation
public class UglyCube extends Applet {
private SimpleUniverse universe ;
public UglyCube() {
}
public void init() {
//canvas to draw on, ask SimpleUniverse what config to use
Canvas3D canvas = new Canvas3D(
SimpleUniverse.getPreferredConfiguration());
setLayout(new BorderLayout());
add("Center", canvas);
//create top of our scene graph
BranchGroup scene = new BranchGroup();
//attach the cube to it
scene.addChild(new ColorCube(0.4));
OrbitBehavior orbit = new OrbitBehavior(canvas);
BoundingSphere bounds =
new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
orbit.setSchedulingBounds(bounds);
//create universe, and attach our geometry to it.
SimpleUniverse u = new SimpleUniverse(canvas);
u.getViewingPlatform().setNominalViewingTransform();
u.getViewingPlatform().setViewPlatformBehavior(orbit);
//rendering starts after BranchGroup is attached.
u.addBranchGraph(scene);
}
// The following allows UglyCube to be run as an application
// as well as an applet
public static void main(String[] args) {
new MainFrame(new UglyCube(), 256, 256);
}
}