/* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Novembre 2001 */ import java.applet.Applet; import java.awt.*; 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.*; public class SimpleBackground extends Applet { public BranchGroup createSceneGraph(SimpleUniverse u) { BranchGroup objRoot = new BranchGroup(); BoundingSphere largeBounds; largeBounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0); { Background bg = new Background(new Color3f(0.5f,0.5f,0.5f)) ; bg.setApplicationBounds(largeBounds) ; objRoot.addChild(bg); } objRoot.compile(); return objRoot; } public SimpleBackground() { setLayout(new BorderLayout()); GraphicsConfiguration config; config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center",c); SimpleUniverse u = new SimpleUniverse(c); BranchGroup scene = createSceneGraph(u); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); } public static void main(String[] args) { new MainFrame(new SimpleBackground(),450,250); } }