★★ Java の宿題ここで答えます Part 61 ★★

このエントリーをはてなブックマークに追加
606デフォルトの名無しさん
import java.applet.Applet;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
public class Java3DProgram extends Applet {
public static void main(String[] args) {
new MainFrame(new Java3DProgram(), 200, 200);
}
public SimpleUniverse universe = null;
public Canvas3D canvas = null;
public void setOrbitBehavior() {
OrbitBehavior orbit = new OrbitBehavior(canvas, OrbitBehavior.REVERSE_ALL);
orbit.setSchedulingBounds(new BoundingSphere(new Point3d(0, 0, 0), 100.0));
universe.getViewingPlatform().setViewPlatformBehavior(orbit);
}
public void init() {
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas = new Canvas3D(config);
add("Center", canvas);
universe = new SimpleUniverse(canvas);
universe.getViewingPlatform().setNominalViewingTransform();
setOrbitBehavior();
BranchGroup root = new BranchGroup();
root.addChild(new ColorCube(0.4));
root.compile();
universe.addBranchGraph(root);
}
}