List of usage examples for javax.media.j3d Canvas3D Canvas3D
public Canvas3D(GraphicsConfiguration graphicsConfiguration)
From source file:LOD.java
public void init() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); u = new SimpleUniverse(c); // only add zoom mouse behavior to viewingPlatform ViewingPlatform viewingPlatform = u.getViewingPlatform(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. viewingPlatform.setNominalViewingTransform(); // add orbit behavior to the ViewingPlatform, but disable rotate // and translate OrbitBehavior orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ZOOM | OrbitBehavior.DISABLE_ROTATE | OrbitBehavior.DISABLE_TRANSLATE); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); orbit.setSchedulingBounds(bounds);/*from w ww. j ava2 s . co m*/ viewingPlatform.setViewPlatformBehavior(orbit); u.addBranchGraph(scene); }
From source file:Text2DApp.java
public Text2DApp() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas3D = new Canvas3D(config); canvas3D.setStereoEnable(false);//from w w w .j av a2 s. co m add("Center", canvas3D); BranchGroup scene = createSceneGraph(); // SimpleUniverse is a Convenience Utility class SimpleUniverse simpleU = new SimpleUniverse(canvas3D); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); }
From source file:ConeYoyoApp.java
public ConeYoyoApp() { setLayout(new BorderLayout()); Canvas3D canvas3D = new Canvas3D(null); add("Center", canvas3D); BranchGroup scene = createSceneGraph(); SimpleUniverse simpleU = new SimpleUniverse(canvas3D); simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene);//from w w w. j a v a2 s . c o m }
From source file:YoyoApp.java
public YoyoApp() { setLayout(new BorderLayout()); Canvas3D canvas3D = new Canvas3D(null); add("Center", canvas3D); BranchGroup scene = createSceneGraph(); // SimpleUniverse is a Convenience Utility class SimpleUniverse simpleU = new SimpleUniverse(canvas3D); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene);/*w w w . j av a2s . co m*/ }
From source file:KeyNavigatorApp.java
public KeyNavigatorApp() { setLayout(new BorderLayout()); Canvas3D canvas3D = new Canvas3D(null); add("Center", canvas3D); // SimpleUniverse is a Convenience Utility class SimpleUniverse simpleU = new SimpleUniverse(canvas3D); BranchGroup scene = createSceneGraph(simpleU); simpleU.addBranchGraph(scene);//from www .j a v a2 s. co m }
From source file:Demo3D.java
/** * Constructor that allows to specify the desired initial instances. *///from w w w .j a va2s.c o m public Demo3D() { // Set the best GraphicsConfiguration GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); GraphicsConfiguration graphConf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template); canvas3D = new Canvas3D(graphConf); // The used Canvas3D // Construction of the main frame. setTitle("Demo"); JPanel jMainPanel = new JPanel(true); jMainPanel.setLayout(new BorderLayout(0, 5)); // hor_gap and ver_gap JPanel jFpsPanel = new JPanel(true); jFpsPanel.setBackground(Color.white); jLabel = new JLabel(""); jLabel.setText("Wait for informations"); jFpsPanel.add(jLabel); jMainPanel.add(canvas3D, BorderLayout.CENTER); /* * // For the stereo-mode with an "Head Monted Display" (HMD). JPanel * jScene_Stereo_Panel = new JPanel(true); * jScene_Stereo_Panel.setLayout(new GridLayout(1, 2, 0, 0)); // rows, * col, hor_gap and ver_gap jScene_Stereo_Panel.add(canvas3D); * jScene_Stereo_Panel.add(canvas3D); * jMainPanel.add(jScene_Stereo_Panel, BorderLayout.CENTER); */ jMainPanel.add(jFpsPanel, BorderLayout.SOUTH); setContentPane(jMainPanel); // The ViewBranch class creates the instances of ViewPlatform, View, // etc. viewBr = new ViewBranch(canvas3D); fpsThread = new Thread(this); myScene(); }
From source file:Drag.java
/** * Calls the various methods necessary to initialize the * program./*from w ww.ja v a2s . co m*/ */ public void init() { // Set the layout manager setLayout(new BorderLayout()); // Create the 3D canvas Canvas3D canvas = new Canvas3D(null); add("Center", canvas); // Create the scene branch graph BranchGroup scene = createSceneGraph(); // Create the Universe, the Locale, and the view branch graph SimpleUniverse u = new SimpleUniverse(canvas); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); }
From source file:Text2DTest.java
public void init() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); u = new SimpleUniverse(c); MoverBehavior navigator = new MoverBehavior(u.getViewingPlatform().getViewPlatformTransform()); scene.addChild(navigator);/*from w w w. j a va 2 s .c o m*/ // Have Java 3D perform optimizations on this scene graph. scene.compile(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); }
From source file:ModelClipTest2.java
public void init() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); u = new SimpleUniverse(c); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene);//from w ww .j a va 2 s .c o m }
From source file:ObjLoad.java
public void init() { if (filename == null) { // Applet try {//from ww w . j a va 2s .co m URL path = getCodeBase(); filename = new URL(path.toString() + "./galleon.obj"); } catch (MalformedURLException e) { System.err.println(e); System.exit(1); } } setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); u = new SimpleUniverse(c); // add mouse behaviors to the ViewingPlatform ViewingPlatform viewingPlatform = u.getViewingPlatform(); PlatformGeometry pg = new PlatformGeometry(); // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); pg.addChild(ambientLightNode); // Set up the directional lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f); Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); pg.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); pg.addChild(light2); viewingPlatform.setPlatformGeometry(pg); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. viewingPlatform.setNominalViewingTransform(); if (!spin) { OrbitBehavior orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ALL); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); orbit.setSchedulingBounds(bounds); viewingPlatform.setViewPlatformBehavior(orbit); } u.addBranchGraph(scene); }