<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2F3D%2FCylinder</id>
		<title>Java/3D/Cylinder - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2F3D%2FCylinder"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/3D/Cylinder&amp;action=history"/>
		<updated>2026-04-06T10:35:20Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/3D/Cylinder&amp;diff=6469&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/3D/Cylinder&amp;diff=6469&amp;oldid=prev"/>
				<updated>2010-06-01T06:15:01Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:15, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/3D/Cylinder&amp;diff=6468&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/3D/Cylinder&amp;diff=6468&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:44Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== PickWorld creates spheres, cylinders, and cones of different resolutions ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 *  @(#)PickWorld.java 1.10 98/04/13 13:49:14&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 1996-1998 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Sun grants you (&amp;quot;Licensee&amp;quot;) a non-exclusive, royalty free, license to use,&lt;br /&gt;
 * modify and redistribute this software in source and binary code form,&lt;br /&gt;
 * provided that i) this copyright notice and license appear on all copies of&lt;br /&gt;
 * the software; and ii) Licensee does not utilize the software in a manner&lt;br /&gt;
 * which is disparaging to Sun.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any kind. ALL&lt;br /&gt;
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY&lt;br /&gt;
 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR&lt;br /&gt;
 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE&lt;br /&gt;
 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING&lt;br /&gt;
 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS&lt;br /&gt;
 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,&lt;br /&gt;
 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER&lt;br /&gt;
 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF&lt;br /&gt;
 * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE&lt;br /&gt;
 * POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is not designed or intended for use in on-line control of&lt;br /&gt;
 * aircraft, air traffic, aircraft navigation or aircraft communications; or in&lt;br /&gt;
 * the design, construction, operation or maintenance of any nuclear&lt;br /&gt;
 * facility. Licensee represents and warrants that it will not use or&lt;br /&gt;
 * redistribute the Software for such purposes.&lt;br /&gt;
 */&lt;br /&gt;
import java.applet.Applet;&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import javax.media.j3d.AmbientLight;&lt;br /&gt;
import javax.media.j3d.Appearance;&lt;br /&gt;
import javax.media.j3d.Background;&lt;br /&gt;
import javax.media.j3d.BoundingSphere;&lt;br /&gt;
import javax.media.j3d.BranchGroup;&lt;br /&gt;
import javax.media.j3d.Canvas3D;&lt;br /&gt;
import javax.media.j3d.ColoringAttributes;&lt;br /&gt;
import javax.media.j3d.DirectionalLight;&lt;br /&gt;
import javax.media.j3d.Group;&lt;br /&gt;
import javax.media.j3d.Material;&lt;br /&gt;
import javax.media.j3d.Transform3D;&lt;br /&gt;
import javax.media.j3d.TransformGroup;&lt;br /&gt;
import javax.vecmath.Color3f;&lt;br /&gt;
import javax.vecmath.Point3d;&lt;br /&gt;
import javax.vecmath.Vector3d;&lt;br /&gt;
import javax.vecmath.Vector3f;&lt;br /&gt;
import com.sun.j3d.utils.applet.MainFrame;&lt;br /&gt;
import com.sun.j3d.utils.behaviors.picking.PickRotateBehavior;&lt;br /&gt;
import com.sun.j3d.utils.behaviors.picking.PickTranslateBehavior;&lt;br /&gt;
import com.sun.j3d.utils.behaviors.picking.PickZoomBehavior;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Cone;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Cylinder;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Primitive;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Sphere;&lt;br /&gt;
import com.sun.j3d.utils.image.TextureLoader;&lt;br /&gt;
import com.sun.j3d.utils.universe.SimpleUniverse;&lt;br /&gt;
/**&lt;br /&gt;
 * PickWorld creates spheres, cylinders, and cones of different resolutions and&lt;br /&gt;
 * colors. You can pick each one and drag/zoom them around. The setup comes from&lt;br /&gt;
 * TickTockPicking.&lt;br /&gt;
 */&lt;br /&gt;
public class PickWorld extends Applet {&lt;br /&gt;
  public BranchGroup createSceneGraph(Canvas3D c) {&lt;br /&gt;
    // Create the root of the branch graph&lt;br /&gt;
    BranchGroup objRoot = new BranchGroup();&lt;br /&gt;
    // Create a Transformgroup to scale all objects so they&lt;br /&gt;
    // appear in the scene.&lt;br /&gt;
    TransformGroup objScale = new TransformGroup();&lt;br /&gt;
    Transform3D t3d = new Transform3D();&lt;br /&gt;
    t3d.setScale(1.0);&lt;br /&gt;
    objScale.setTransform(t3d);&lt;br /&gt;
    objRoot.addChild(objScale);&lt;br /&gt;
    // Create a bounds for the background and behaviors&lt;br /&gt;
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),&lt;br /&gt;
        100.0);&lt;br /&gt;
    // Attach picking behavior utlities to the scene root.&lt;br /&gt;
    // They will wake up when user manipulates a scene node.&lt;br /&gt;
    PickRotateBehavior behavior = new PickRotateBehavior(objRoot, c, bounds);&lt;br /&gt;
    objRoot.addChild(behavior);&lt;br /&gt;
    PickZoomBehavior behavior2 = new PickZoomBehavior(objRoot, c, bounds);&lt;br /&gt;
    objRoot.addChild(behavior2);&lt;br /&gt;
    PickTranslateBehavior behavior3 = new PickTranslateBehavior(objRoot, c,&lt;br /&gt;
        bounds);&lt;br /&gt;
    objRoot.addChild(behavior3);&lt;br /&gt;
    // Set up the background&lt;br /&gt;
    Color3f bgColor = new Color3f(0.05f, 0.05f, 0.4f);&lt;br /&gt;
    Background bg = new Background(bgColor);&lt;br /&gt;
    bg.setApplicationBounds(bounds);&lt;br /&gt;
    objRoot.addChild(bg);&lt;br /&gt;
    // Set up the global lights&lt;br /&gt;
    Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);&lt;br /&gt;
    Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);&lt;br /&gt;
    Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);&lt;br /&gt;
    AmbientLight aLgt = new AmbientLight(alColor);&lt;br /&gt;
    aLgt.setInfluencingBounds(bounds);&lt;br /&gt;
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);&lt;br /&gt;
    lgt1.setInfluencingBounds(bounds);&lt;br /&gt;
    objRoot.addChild(aLgt);&lt;br /&gt;
    objRoot.addChild(lgt1);&lt;br /&gt;
    // Create a bunch of objects with a behavior and add them&lt;br /&gt;
    // into the scene graph.&lt;br /&gt;
    int row, col;&lt;br /&gt;
    int numRows = 3, numCols = 5;&lt;br /&gt;
    Appearance[][] app = new Appearance[numRows][numCols];&lt;br /&gt;
    for (row = 0; row &amp;lt; numRows; row++)&lt;br /&gt;
      for (col = 0; col &amp;lt; numCols; col++)&lt;br /&gt;
        app[row][col] = createAppearance(row * numCols + col);&lt;br /&gt;
    for (int i = 0; i &amp;lt; numRows; i++) {&lt;br /&gt;
      double ypos = (double) (i - numRows / 2) * 0.6;&lt;br /&gt;
      for (int j = 0; j &amp;lt; numCols; j++) {&lt;br /&gt;
        double xpos = (double) (j - numCols / 2) * 0.4;&lt;br /&gt;
        objScale&lt;br /&gt;
            .addChild(createObject(i, j, app[i][j], 0.1, xpos, ypos));&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // Let Java 3D perform optimizations on this scene graph.&lt;br /&gt;
    objRoot.rupile();&lt;br /&gt;
    return objRoot;&lt;br /&gt;
  }&lt;br /&gt;
  private Appearance createAppearance(int idx) {&lt;br /&gt;
    Appearance app = new Appearance();&lt;br /&gt;
    // Globally used colors&lt;br /&gt;
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);&lt;br /&gt;
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);&lt;br /&gt;
    Color3f gray = new Color3f(0.4f, 0.4f, 0.4f);&lt;br /&gt;
    idx = idx % 5;&lt;br /&gt;
    switch (idx) {&lt;br /&gt;
    // Lit solid&lt;br /&gt;
    case 0: {&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      Color3f objColor = new Color3f(0.0f, 0.8f, 0.0f);&lt;br /&gt;
      app.setMaterial(new Material(objColor, black, objColor, white,&lt;br /&gt;
          80.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    // Lit solid, specular only&lt;br /&gt;
    case 1: {&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      Color3f objColor = new Color3f(0.0f, 0.4f, 0.2f);&lt;br /&gt;
      app.setMaterial(new Material(black, black, objColor, white, 80.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    case 2: {&lt;br /&gt;
      // Set up the texture map&lt;br /&gt;
      TextureLoader tex = new TextureLoader(&amp;quot;apimage.jpg&amp;quot;, this);&lt;br /&gt;
      app.setTexture(tex.getTexture());&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      app.setMaterial(new Material(gray, black, gray, white, 1.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    // Texture mapped, lit solid&lt;br /&gt;
    case 3: {&lt;br /&gt;
      // Set up the texture map&lt;br /&gt;
      TextureLoader tex = new TextureLoader(&amp;quot;earth.jpg&amp;quot;, this);&lt;br /&gt;
      app.setTexture(tex.getTexture());&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      app.setMaterial(new Material(gray, black, gray, white, 1.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    // Another lit solid with a different color&lt;br /&gt;
    case 4: {&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      Color3f objColor = new Color3f(1.0f, 1.0f, 0.0f);&lt;br /&gt;
      app.setMaterial(new Material(objColor, black, objColor, white,&lt;br /&gt;
          80.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    default: {&lt;br /&gt;
      ColoringAttributes ca = new ColoringAttributes();&lt;br /&gt;
      ca.setColor(new Color3f(0.0f, 1.0f, 0.0f));&lt;br /&gt;
      app.setColoringAttributes(ca);&lt;br /&gt;
    }&lt;br /&gt;
    }&lt;br /&gt;
    return app;&lt;br /&gt;
  }&lt;br /&gt;
  private Group createObject(int i, int j, Appearance app, double scale,&lt;br /&gt;
      double xpos, double ypos) {&lt;br /&gt;
    // Create a transform group node to scale and position the object.&lt;br /&gt;
    Transform3D t = new Transform3D();&lt;br /&gt;
    t.set(scale, new Vector3d(xpos, ypos, 0.0));&lt;br /&gt;
    TransformGroup objTrans = new TransformGroup(t);&lt;br /&gt;
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);&lt;br /&gt;
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);&lt;br /&gt;
    objTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING);&lt;br /&gt;
    // Create a second transform group node and initialize it to the&lt;br /&gt;
    // identity. Enable the TRANSFORM_WRITE capability so that&lt;br /&gt;
    // our behavior code can modify it at runtime.&lt;br /&gt;
    TransformGroup spinTg = new TransformGroup();&lt;br /&gt;
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);&lt;br /&gt;
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);&lt;br /&gt;
    spinTg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);&lt;br /&gt;
    Primitive obj = null;&lt;br /&gt;
    if (i % 3 == 2) {&lt;br /&gt;
      obj = (Primitive) new Sphere(1.0f, Sphere.GENERATE_NORMALS&lt;br /&gt;
          | Sphere.GENERATE_TEXTURE_COORDS, j * 8 + 4, app);&lt;br /&gt;
    } else if (i % 3 == 1) {&lt;br /&gt;
      obj = (Primitive) new Cylinder(1.0f, 2.0f,&lt;br /&gt;
          Cylinder.GENERATE_TEXTURE_COORDS&lt;br /&gt;
              | Cylinder.GENERATE_NORMALS, j * 8 + 4, j * 8 + 4,&lt;br /&gt;
          app);&lt;br /&gt;
    } else if (i % 3 == 0) {&lt;br /&gt;
      obj = (Primitive) new Cone(1.0f, 2.0f, Cone.GENERATE_NORMALS&lt;br /&gt;
          | Cone.GENERATE_TEXTURE_COORDS, j * 8 + 4, j * 8 + 4, app);&lt;br /&gt;
    }&lt;br /&gt;
    // add it to the scene graph.&lt;br /&gt;
    spinTg.addChild(obj);&lt;br /&gt;
    objTrans.addChild(spinTg);&lt;br /&gt;
    return objTrans;&lt;br /&gt;
  }&lt;br /&gt;
  public PickWorld() {&lt;br /&gt;
    setLayout(new BorderLayout());&lt;br /&gt;
    Canvas3D c = new Canvas3D(null);&lt;br /&gt;
    add(&amp;quot;Center&amp;quot;, c);&lt;br /&gt;
    // Create a simple scene and attach it to the virtual universe&lt;br /&gt;
    BranchGroup scene = createSceneGraph(c);&lt;br /&gt;
    SimpleUniverse u = new SimpleUniverse(c);&lt;br /&gt;
    // This will move the ViewPlatform back a bit so the&lt;br /&gt;
    // objects in the scene can be viewed.&lt;br /&gt;
    u.getViewingPlatform().setNominalViewingTransform();&lt;br /&gt;
    u.addBranchGraph(scene);&lt;br /&gt;
  }&lt;br /&gt;
  //&lt;br /&gt;
  // The following allows PickWorld to be run as an application&lt;br /&gt;
  // as well as an applet&lt;br /&gt;
  //&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    new MainFrame(new PickWorld(), 640, 480);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Spheres, cylinders, and cones of different resolutions and colors ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 *  @(#)ConicWorld.java 1.27 02/10/21 13:38:29&lt;br /&gt;
 *&lt;br /&gt;
 * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions&lt;br /&gt;
 * are met:&lt;br /&gt;
 *&lt;br /&gt;
 * - Redistributions of source code must retain the above copyright&lt;br /&gt;
 *   notice, this list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 * - Redistribution in binary form must reproduce the above copyright&lt;br /&gt;
 *   notice, this list of conditions and the following disclaimer in&lt;br /&gt;
 *   the documentation and/or other materials provided with the&lt;br /&gt;
 *   distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * Neither the name of Sun Microsystems, Inc. or the names of&lt;br /&gt;
 * contributors may be used to endorse or promote products derived&lt;br /&gt;
 * from this software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is provided &amp;quot;AS IS,&amp;quot; without a warranty of any&lt;br /&gt;
 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND&lt;br /&gt;
 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,&lt;br /&gt;
 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY&lt;br /&gt;
 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES&lt;br /&gt;
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR&lt;br /&gt;
 * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN&lt;br /&gt;
 * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR&lt;br /&gt;
 * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR&lt;br /&gt;
 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF&lt;br /&gt;
 * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,&lt;br /&gt;
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.&lt;br /&gt;
 *&lt;br /&gt;
 * You acknowledge that Software is not designed,licensed or intended&lt;br /&gt;
 * for use in the design, construction, operation or maintenance of&lt;br /&gt;
 * any nuclear facility.&lt;br /&gt;
 */&lt;br /&gt;
import java.applet.Applet;&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.GraphicsConfiguration;&lt;br /&gt;
import javax.media.j3d.Alpha;&lt;br /&gt;
import javax.media.j3d.AmbientLight;&lt;br /&gt;
import javax.media.j3d.Appearance;&lt;br /&gt;
import javax.media.j3d.Background;&lt;br /&gt;
import javax.media.j3d.BoundingSphere;&lt;br /&gt;
import javax.media.j3d.BranchGroup;&lt;br /&gt;
import javax.media.j3d.Canvas3D;&lt;br /&gt;
import javax.media.j3d.ColoringAttributes;&lt;br /&gt;
import javax.media.j3d.DirectionalLight;&lt;br /&gt;
import javax.media.j3d.Group;&lt;br /&gt;
import javax.media.j3d.Material;&lt;br /&gt;
import javax.media.j3d.RotationInterpolator;&lt;br /&gt;
import javax.media.j3d.TextureAttributes;&lt;br /&gt;
import javax.media.j3d.Transform3D;&lt;br /&gt;
import javax.media.j3d.TransformGroup;&lt;br /&gt;
import javax.vecmath.Color3f;&lt;br /&gt;
import javax.vecmath.Point3d;&lt;br /&gt;
import javax.vecmath.Vector3d;&lt;br /&gt;
import javax.vecmath.Vector3f;&lt;br /&gt;
import com.sun.j3d.utils.applet.MainFrame;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Cone;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Cylinder;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Primitive;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Sphere;&lt;br /&gt;
import com.sun.j3d.utils.image.TextureLoader;&lt;br /&gt;
import com.sun.j3d.utils.universe.SimpleUniverse;&lt;br /&gt;
/**&lt;br /&gt;
 * ConicWorld creates spheres, cylinders, and cones of different resolutions and&lt;br /&gt;
 * colors. Demonstrates the use of the various geometry creation constructors&lt;br /&gt;
 * found in the com.sun.j3d.utils.geometry package.&lt;br /&gt;
 */&lt;br /&gt;
public class ConicWorld extends Applet {&lt;br /&gt;
  private java.net.URL texImage = null;&lt;br /&gt;
  private SimpleUniverse u = null;&lt;br /&gt;
  public BranchGroup createSceneGraph(Canvas3D c) {&lt;br /&gt;
    // Create the root of the branch graph&lt;br /&gt;
    BranchGroup objRoot = new BranchGroup();&lt;br /&gt;
    // Create a bounds for the background and behaviors&lt;br /&gt;
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),&lt;br /&gt;
        100.0);&lt;br /&gt;
    // Set up the background&lt;br /&gt;
    Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);&lt;br /&gt;
    Background bg = new Background(bgColor);&lt;br /&gt;
    bg.setApplicationBounds(bounds);&lt;br /&gt;
    objRoot.addChild(bg);&lt;br /&gt;
    // Set up the global lights&lt;br /&gt;
    Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);&lt;br /&gt;
    Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);&lt;br /&gt;
    Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);&lt;br /&gt;
    AmbientLight aLgt = new AmbientLight(alColor);&lt;br /&gt;
    aLgt.setInfluencingBounds(bounds);&lt;br /&gt;
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);&lt;br /&gt;
    lgt1.setInfluencingBounds(bounds);&lt;br /&gt;
    objRoot.addChild(aLgt);&lt;br /&gt;
    objRoot.addChild(lgt1);&lt;br /&gt;
    // Create a bunch of objects with a behavior and add them&lt;br /&gt;
    // into the scene graph.&lt;br /&gt;
    int row, col;&lt;br /&gt;
    int numRows = 3, numCols = 5;&lt;br /&gt;
    Appearance[][] app = new Appearance[numRows][numCols];&lt;br /&gt;
    for (row = 0; row &amp;lt; numRows; row++)&lt;br /&gt;
      for (col = 0; col &amp;lt; numCols; col++)&lt;br /&gt;
        app[row][col] = createAppearance(row * numCols + col);&lt;br /&gt;
    // Space between each row/column&lt;br /&gt;
    double xspace = 2.0 / ((double) numCols - 1.0);&lt;br /&gt;
    double yspace = 2.0 / ((double) numRows - 1.0);&lt;br /&gt;
    for (int i = 0; i &amp;lt; numRows; i++) {&lt;br /&gt;
      double ypos = ((double) i * yspace - 1.0) * 0.6;&lt;br /&gt;
      for (int j = 0; j &amp;lt; numCols; j++) {&lt;br /&gt;
        double xpos = xpos = ((double) j * xspace - 1.0) * 0.6;&lt;br /&gt;
        objRoot&lt;br /&gt;
            .addChild(createObject(i, j, app[i][j], 0.1, xpos, ypos));&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // Let Java 3D perform optimizations on this scene graph.&lt;br /&gt;
    objRoot.rupile();&lt;br /&gt;
    return objRoot;&lt;br /&gt;
  }&lt;br /&gt;
  private Appearance createAppearance(int idx) {&lt;br /&gt;
    Appearance app = new Appearance();&lt;br /&gt;
    // Globally used colors&lt;br /&gt;
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);&lt;br /&gt;
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);&lt;br /&gt;
    idx = idx % 5;&lt;br /&gt;
    switch (idx) {&lt;br /&gt;
    // Lit solid&lt;br /&gt;
    case 0: {&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f);&lt;br /&gt;
      app.setMaterial(new Material(objColor, black, objColor, white,&lt;br /&gt;
          80.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    // Lit solid, no specular&lt;br /&gt;
    case 1: {&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      Color3f objColor = new Color3f(0.0f, 0.8f, 0.0f);&lt;br /&gt;
      app.setMaterial(new Material(objColor, black, objColor, white,&lt;br /&gt;
          80.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    // Lit solid, specular only&lt;br /&gt;
    case 2: {&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      Color3f objColor = new Color3f(0.0f, 0.8f, 0.8f);&lt;br /&gt;
      app.setMaterial(new Material(black, black, objColor, white, 80.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    // Texture mapped, lit solid&lt;br /&gt;
    case 3: {&lt;br /&gt;
      // Set up the texture map&lt;br /&gt;
      TextureLoader tex = new TextureLoader(texImage, this);&lt;br /&gt;
      app.setTexture(tex.getTexture());&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      app.setMaterial(new Material(white, black, white, black, 1.0f));&lt;br /&gt;
      TextureAttributes texAttr = new TextureAttributes();&lt;br /&gt;
      texAttr.setTextureMode(TextureAttributes.MODULATE);&lt;br /&gt;
      app.setTextureAttributes(texAttr);&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    // Another lit solid with a different color&lt;br /&gt;
    case 4: {&lt;br /&gt;
      // Set up the material properties&lt;br /&gt;
      Color3f objColor = new Color3f(1.0f, 1.0f, 0.0f);&lt;br /&gt;
      app.setMaterial(new Material(objColor, black, objColor, white,&lt;br /&gt;
          80.0f));&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
    default: {&lt;br /&gt;
      ColoringAttributes ca = new ColoringAttributes();&lt;br /&gt;
      ca.setColor(new Color3f(0.0f, 1.0f, 0.0f));&lt;br /&gt;
      app.setColoringAttributes(ca);&lt;br /&gt;
    }&lt;br /&gt;
    }&lt;br /&gt;
    return app;&lt;br /&gt;
  }&lt;br /&gt;
  private Group createObject(int i, int j, Appearance app, double scale,&lt;br /&gt;
      double xpos, double ypos) {&lt;br /&gt;
    // Create a transform group node to scale and position the object.&lt;br /&gt;
    Transform3D t = new Transform3D();&lt;br /&gt;
    t.set(scale, new Vector3d(xpos, ypos, 0.0));&lt;br /&gt;
    TransformGroup objTrans = new TransformGroup(t);&lt;br /&gt;
    // Create a second transform group node and initialize it to the&lt;br /&gt;
    // identity. Enable the TRANSFORM_WRITE capability so that&lt;br /&gt;
    // our behavior code can modify it at runtime.&lt;br /&gt;
    TransformGroup spinTg = new TransformGroup();&lt;br /&gt;
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);&lt;br /&gt;
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);&lt;br /&gt;
    Primitive obj = null;&lt;br /&gt;
    if (i % 3 == 2) {&lt;br /&gt;
      obj = (Primitive) new Sphere(1.0f, Sphere.GENERATE_NORMALS&lt;br /&gt;
          | Sphere.GENERATE_TEXTURE_COORDS, j * 8 + 4, app);&lt;br /&gt;
    } else if (i % 3 == 1) {&lt;br /&gt;
      obj = (Primitive) new Cylinder(1.0f, 2.0f,&lt;br /&gt;
          Cylinder.GENERATE_TEXTURE_COORDS&lt;br /&gt;
              | Cylinder.GENERATE_NORMALS, j * 8 + 4, j * 8 + 4,&lt;br /&gt;
          app);&lt;br /&gt;
    } else if (i % 3 == 0) {&lt;br /&gt;
      obj = (Primitive) new Cone(1.0f, 2.0f, Cone.GENERATE_NORMALS&lt;br /&gt;
          | Cone.GENERATE_TEXTURE_COORDS, j * 8 + 4, j * 8 + 4, app);&lt;br /&gt;
    }&lt;br /&gt;
    // add it to the scene graph.&lt;br /&gt;
    spinTg.addChild(obj);&lt;br /&gt;
    // Create a new Behavior object that will perform the desired&lt;br /&gt;
    // operation on the specified transform object and add it into&lt;br /&gt;
    // the scene graph.&lt;br /&gt;
    Transform3D yAxis = new Transform3D();&lt;br /&gt;
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0,&lt;br /&gt;
        5000, 0, 0, 0, 0, 0);&lt;br /&gt;
    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha,&lt;br /&gt;
        spinTg, yAxis, 0.0f, (float) Math.PI * 2.0f);&lt;br /&gt;
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0),&lt;br /&gt;
        100.0);&lt;br /&gt;
    rotator.setSchedulingBounds(bounds);&lt;br /&gt;
    // Add the behavior and the transform group to the object&lt;br /&gt;
    objTrans.addChild(rotator);&lt;br /&gt;
    objTrans.addChild(spinTg);&lt;br /&gt;
    return objTrans;&lt;br /&gt;
  }&lt;br /&gt;
  public ConicWorld() {&lt;br /&gt;
  }&lt;br /&gt;
  public ConicWorld(java.net.URL url) {&lt;br /&gt;
    texImage = url;&lt;br /&gt;
  }&lt;br /&gt;
  public void init() {&lt;br /&gt;
    if (texImage == null) {&lt;br /&gt;
      // the path to the image for an applet&lt;br /&gt;
      try {&lt;br /&gt;
        texImage = new java.net.URL(getCodeBase().toString()&lt;br /&gt;
            + &amp;quot;/earth.jpg&amp;quot;);&lt;br /&gt;
      } catch (java.net.MalformedURLException ex) {&lt;br /&gt;
        System.out.println(ex.getMessage());&lt;br /&gt;
        System.exit(1);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    setLayout(new BorderLayout());&lt;br /&gt;
    GraphicsConfiguration config = SimpleUniverse&lt;br /&gt;
        .getPreferredConfiguration();&lt;br /&gt;
    Canvas3D c = new Canvas3D(config);&lt;br /&gt;
    add(&amp;quot;Center&amp;quot;, c);&lt;br /&gt;
    // Create a simple scene and attach it to the virtual universe&lt;br /&gt;
    BranchGroup scene = createSceneGraph(c);&lt;br /&gt;
    u = new SimpleUniverse(c);&lt;br /&gt;
    // This will move the ViewPlatform back a bit so the&lt;br /&gt;
    // objects in the scene can be viewed.&lt;br /&gt;
    u.getViewingPlatform().setNominalViewingTransform();&lt;br /&gt;
    u.addBranchGraph(scene);&lt;br /&gt;
  }&lt;br /&gt;
  public void destroy() {&lt;br /&gt;
    u.cleanup();&lt;br /&gt;
  }&lt;br /&gt;
  //&lt;br /&gt;
  // The following allows ConicWorld to be run as an application&lt;br /&gt;
  // as well as an applet&lt;br /&gt;
  //&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // the path to the image file for an application&lt;br /&gt;
    java.net.URL url = null;&lt;br /&gt;
    try {&lt;br /&gt;
      url = new java.net.URL(&amp;quot;file:earth.jpg&amp;quot;);&lt;br /&gt;
    } catch (java.net.MalformedURLException ex) {&lt;br /&gt;
      System.out.println(ex.getMessage());&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    }&lt;br /&gt;
    new MainFrame(new ConicWorld(url), 700, 700);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== This creates a simple cylinder by using the Cylinder utility class ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
Essential Java 3D Fast&lt;br /&gt;
Ian Palmer&lt;br /&gt;
Publisher: Springer-Verlag&lt;br /&gt;
ISBN: 1-85233-394-4&lt;br /&gt;
*/&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Button;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import javax.media.j3d.Appearance;&lt;br /&gt;
import javax.media.j3d.BranchGroup;&lt;br /&gt;
import javax.media.j3d.Canvas3D;&lt;br /&gt;
import javax.media.j3d.Locale;&lt;br /&gt;
import javax.media.j3d.PhysicalBody;&lt;br /&gt;
import javax.media.j3d.PhysicalEnvironment;&lt;br /&gt;
import javax.media.j3d.Transform3D;&lt;br /&gt;
import javax.media.j3d.TransformGroup;&lt;br /&gt;
import javax.media.j3d.View;&lt;br /&gt;
import javax.media.j3d.ViewPlatform;&lt;br /&gt;
import javax.media.j3d.VirtualUniverse;&lt;br /&gt;
import javax.vecmath.AxisAngle4d;&lt;br /&gt;
import javax.vecmath.Vector3f;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Cylinder;&lt;br /&gt;
/**&lt;br /&gt;
 * This creates a simple cylinder by using the Cylinder utility class.&lt;br /&gt;
 * &lt;br /&gt;
 * @author I.J.Palmer&lt;br /&gt;
 * @version 1.0&lt;br /&gt;
 */&lt;br /&gt;
public class SimpleCylinder extends Frame implements ActionListener {&lt;br /&gt;
  protected Canvas3D myCanvas3D = new Canvas3D(null);&lt;br /&gt;
  protected Button myButton = new Button(&amp;quot;Exit&amp;quot;);&lt;br /&gt;
  /**&lt;br /&gt;
   * This function builds the view branch of the scene graph. It creates a&lt;br /&gt;
   * branch group and then creates the necessary view elements to give a&lt;br /&gt;
   * useful view of our content.&lt;br /&gt;
   * &lt;br /&gt;
   * @param c&lt;br /&gt;
   *            Canvas3D that will display the view&lt;br /&gt;
   * @return BranchGroup that is the root of the view elements&lt;br /&gt;
   */&lt;br /&gt;
  protected BranchGroup buildViewBranch(Canvas3D c) {&lt;br /&gt;
    BranchGroup viewBranch = new BranchGroup();&lt;br /&gt;
    Transform3D viewXfm = new Transform3D();&lt;br /&gt;
    viewXfm.set(new Vector3f(0.0f, 0.0f, 5.0f));&lt;br /&gt;
    TransformGroup viewXfmGroup = new TransformGroup(viewXfm);&lt;br /&gt;
    ViewPlatform myViewPlatform = new ViewPlatform();&lt;br /&gt;
    PhysicalBody myBody = new PhysicalBody();&lt;br /&gt;
    PhysicalEnvironment myEnvironment = new PhysicalEnvironment();&lt;br /&gt;
    viewXfmGroup.addChild(myViewPlatform);&lt;br /&gt;
    viewBranch.addChild(viewXfmGroup);&lt;br /&gt;
    View myView = new View();&lt;br /&gt;
    myView.addCanvas3D(c);&lt;br /&gt;
    myView.attachViewPlatform(myViewPlatform);&lt;br /&gt;
    myView.setPhysicalBody(myBody);&lt;br /&gt;
    myView.setPhysicalEnvironment(myEnvironment);&lt;br /&gt;
    return viewBranch;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * This builds the content branch of our scene graph. It uses the Cylinder&lt;br /&gt;
   * utility class to create the actual shape, adding to to the transform&lt;br /&gt;
   * group so that the shape is slightly tilted to reveal its 3D shape.&lt;br /&gt;
   * &lt;br /&gt;
   * @param shape&lt;br /&gt;
   *            Node that represents the geometry for the content&lt;br /&gt;
   * @return BranchGroup that is the root of the content branch&lt;br /&gt;
   */&lt;br /&gt;
  protected BranchGroup buildContentBranch() {&lt;br /&gt;
    BranchGroup contentBranch = new BranchGroup();&lt;br /&gt;
    Transform3D rotateCube = new Transform3D();&lt;br /&gt;
    rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0));&lt;br /&gt;
    TransformGroup rotationGroup = new TransformGroup(rotateCube);&lt;br /&gt;
    contentBranch.addChild(rotationGroup);&lt;br /&gt;
    //Create the shape and add it to the branch&lt;br /&gt;
    rotationGroup.addChild(new Cylinder(1.0f, 1.0f, new Appearance()));&lt;br /&gt;
    return contentBranch;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Handles the exit button action to quit the program.&lt;br /&gt;
   */&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    dispose();&lt;br /&gt;
    System.exit(0);&lt;br /&gt;
  }&lt;br /&gt;
  public SimpleCylinder() {&lt;br /&gt;
    VirtualUniverse myUniverse = new VirtualUniverse();&lt;br /&gt;
    Locale myLocale = new Locale(myUniverse);&lt;br /&gt;
    myLocale.addBranchGraph(buildViewBranch(myCanvas3D));&lt;br /&gt;
    myLocale.addBranchGraph(buildContentBranch());&lt;br /&gt;
    setTitle(&amp;quot;SimpleCylinder&amp;quot;);&lt;br /&gt;
    setSize(400, 400);&lt;br /&gt;
    setLayout(new BorderLayout());&lt;br /&gt;
    add(&amp;quot;Center&amp;quot;, myCanvas3D);&lt;br /&gt;
    add(&amp;quot;South&amp;quot;, myButton);&lt;br /&gt;
    myButton.addActionListener(this);&lt;br /&gt;
    setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    SimpleCylinder sw = new SimpleCylinder();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Three resolutions of a cylinder to demonstrate ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
Essential Java 3D Fast&lt;br /&gt;
Ian Palmer&lt;br /&gt;
Publisher: Springer-Verlag&lt;br /&gt;
ISBN: 1-85233-394-4&lt;br /&gt;
*/&lt;br /&gt;
import java.awt.BorderLayout;&lt;br /&gt;
import java.awt.Button;&lt;br /&gt;
import java.awt.Frame;&lt;br /&gt;
import java.awt.Panel;&lt;br /&gt;
import java.awt.event.ActionEvent;&lt;br /&gt;
import java.awt.event.ActionListener;&lt;br /&gt;
import javax.media.j3d.AmbientLight;&lt;br /&gt;
import javax.media.j3d.Appearance;&lt;br /&gt;
import javax.media.j3d.BoundingLeaf;&lt;br /&gt;
import javax.media.j3d.BoundingSphere;&lt;br /&gt;
import javax.media.j3d.BranchGroup;&lt;br /&gt;
import javax.media.j3d.Canvas3D;&lt;br /&gt;
import javax.media.j3d.DirectionalLight;&lt;br /&gt;
import javax.media.j3d.DistanceLOD;&lt;br /&gt;
import javax.media.j3d.Locale;&lt;br /&gt;
import javax.media.j3d.Material;&lt;br /&gt;
import javax.media.j3d.PhysicalBody;&lt;br /&gt;
import javax.media.j3d.PhysicalEnvironment;&lt;br /&gt;
import javax.media.j3d.Switch;&lt;br /&gt;
import javax.media.j3d.Transform3D;&lt;br /&gt;
import javax.media.j3d.TransformGroup;&lt;br /&gt;
import javax.media.j3d.View;&lt;br /&gt;
import javax.media.j3d.ViewPlatform;&lt;br /&gt;
import javax.media.j3d.VirtualUniverse;&lt;br /&gt;
import javax.vecmath.Color3f;&lt;br /&gt;
import javax.vecmath.Point3d;&lt;br /&gt;
import javax.vecmath.Point3f;&lt;br /&gt;
import javax.vecmath.Vector3f;&lt;br /&gt;
import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior;&lt;br /&gt;
import com.sun.j3d.utils.geometry.Cylinder;&lt;br /&gt;
/**&lt;br /&gt;
 * This uses three resolutions of a cylinder to demonstrate the operation of a&lt;br /&gt;
 * level of detail node.&lt;br /&gt;
 * &lt;br /&gt;
 * @author I.J.Palmer&lt;br /&gt;
 * @version 1.0&lt;br /&gt;
 */&lt;br /&gt;
public class SimpleLOD extends Frame implements ActionListener {&lt;br /&gt;
  protected Canvas3D myCanvas3D = new Canvas3D(null);&lt;br /&gt;
  protected Button exitButton = new Button(&amp;quot;Exit&amp;quot;);&lt;br /&gt;
  protected BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0,&lt;br /&gt;
      0.0), 100.0);&lt;br /&gt;
  /**&lt;br /&gt;
   * Build the view branch of the scene graph. In this case a key navigation&lt;br /&gt;
   * utility object is created and associated with the view transform so that&lt;br /&gt;
   * the view can be changed via the keyboard.&lt;br /&gt;
   * &lt;br /&gt;
   * @return BranchGroup that is the root of the view branch&lt;br /&gt;
   */&lt;br /&gt;
  protected BranchGroup buildViewBranch(Canvas3D c) {&lt;br /&gt;
    BranchGroup viewBranch = new BranchGroup();&lt;br /&gt;
    Transform3D viewXfm = new Transform3D();&lt;br /&gt;
    viewXfm.set(new Vector3f(0.0f, 0.0f, 10.0f));&lt;br /&gt;
    TransformGroup viewXfmGroup = new TransformGroup(viewXfm);&lt;br /&gt;
    viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);&lt;br /&gt;
    viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);&lt;br /&gt;
    BoundingSphere movingBounds = new BoundingSphere(new Point3d(0.0, 0.0,&lt;br /&gt;
        0.0), 100.0);&lt;br /&gt;
    BoundingLeaf boundLeaf = new BoundingLeaf(movingBounds);&lt;br /&gt;
    ViewPlatform myViewPlatform = new ViewPlatform();&lt;br /&gt;
    viewXfmGroup.addChild(boundLeaf);&lt;br /&gt;
    PhysicalBody myBody = new PhysicalBody();&lt;br /&gt;
    PhysicalEnvironment myEnvironment = new PhysicalEnvironment();&lt;br /&gt;
    viewXfmGroup.addChild(myViewPlatform);&lt;br /&gt;
    viewBranch.addChild(viewXfmGroup);&lt;br /&gt;
    View myView = new View();&lt;br /&gt;
    myView.addCanvas3D(c);&lt;br /&gt;
    myView.attachViewPlatform(myViewPlatform);&lt;br /&gt;
    myView.setPhysicalBody(myBody);&lt;br /&gt;
    myView.setPhysicalEnvironment(myEnvironment);&lt;br /&gt;
    KeyNavigatorBehavior keyNav = new KeyNavigatorBehavior(viewXfmGroup);&lt;br /&gt;
    keyNav.setSchedulingBounds(movingBounds);&lt;br /&gt;
    viewBranch.addChild(keyNav);&lt;br /&gt;
    return viewBranch;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Add some lights to the scene graph&lt;br /&gt;
   * &lt;br /&gt;
   * @param b&lt;br /&gt;
   *            BranchGroup that the lights are added to&lt;br /&gt;
   */&lt;br /&gt;
  protected void addLights(BranchGroup b) {&lt;br /&gt;
    Color3f ambLightColour = new Color3f(0.5f, 0.5f, 0.5f);&lt;br /&gt;
    AmbientLight ambLight = new AmbientLight(ambLightColour);&lt;br /&gt;
    ambLight.setInfluencingBounds(bounds);&lt;br /&gt;
    Color3f dirLightColour = new Color3f(1.0f, 1.0f, 1.0f);&lt;br /&gt;
    Vector3f dirLightDir = new Vector3f(-1.0f, -1.0f, -1.0f);&lt;br /&gt;
    DirectionalLight dirLight = new DirectionalLight(dirLightColour,&lt;br /&gt;
        dirLightDir);&lt;br /&gt;
    dirLight.setInfluencingBounds(bounds);&lt;br /&gt;
    b.addChild(ambLight);&lt;br /&gt;
    b.addChild(dirLight);&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Build the content branch for the scene graph This creates three&lt;br /&gt;
   * cylinders, each with a different resolution. These are then used with a&lt;br /&gt;
   * LOD node to implement a crude level of detail.&lt;br /&gt;
   * &lt;br /&gt;
   * @return BranchGroup that is the root of the content&lt;br /&gt;
   */&lt;br /&gt;
  protected BranchGroup buildContentBranch() {&lt;br /&gt;
    //Create the appearance&lt;br /&gt;
    Appearance app = new Appearance();&lt;br /&gt;
    Color3f ambientColour = new Color3f(1.0f, 1.0f, 0.0f);&lt;br /&gt;
    Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f);&lt;br /&gt;
    Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f);&lt;br /&gt;
    Color3f diffuseColour = new Color3f(1.0f, 1.0f, 0.0f);&lt;br /&gt;
    float shininess = 20.0f;&lt;br /&gt;
    app.setMaterial(new Material(ambientColour, emissiveColour,&lt;br /&gt;
        diffuseColour, specularColour, shininess));&lt;br /&gt;
    //Make the switch node that is to used with the LOD&lt;br /&gt;
    //and make it writable&lt;br /&gt;
    Switch LODswitch = new Switch();&lt;br /&gt;
    LODswitch.setCapability(Switch.ALLOW_SWITCH_WRITE);&lt;br /&gt;
    //Add the three cylinders&lt;br /&gt;
    LODswitch.addChild(new Cylinder(1.0f, 1.0f, Cylinder.GENERATE_NORMALS,&lt;br /&gt;
        10, 10, app));&lt;br /&gt;
    LODswitch.addChild(new Cylinder(1.0f, 1.0f, Cylinder.GENERATE_NORMALS,&lt;br /&gt;
        5, 5, app));&lt;br /&gt;
    LODswitch.addChild(new Cylinder(1.0f, 1.0f, Cylinder.GENERATE_NORMALS,&lt;br /&gt;
        3, 3, app));&lt;br /&gt;
    //Define the distances for the LOD&lt;br /&gt;
    float[] LODdistances = { 5.0f, 10.0f, 15.0f };&lt;br /&gt;
    DistanceLOD myLOD = new DistanceLOD(LODdistances, new Point3f(0.0f,&lt;br /&gt;
        0.0f, 0.0f));&lt;br /&gt;
    myLOD.setSchedulingBounds(bounds);&lt;br /&gt;
    //Add the switch to the LOD&lt;br /&gt;
    myLOD.addSwitch(LODswitch);&lt;br /&gt;
    BranchGroup contentBranch = new BranchGroup();&lt;br /&gt;
    contentBranch.addChild(myLOD);&lt;br /&gt;
    addLights(contentBranch);&lt;br /&gt;
    contentBranch.addChild(LODswitch);&lt;br /&gt;
    return contentBranch;&lt;br /&gt;
  }&lt;br /&gt;
  /**&lt;br /&gt;
   * Use the action event of the exit button to end the application.&lt;br /&gt;
   */&lt;br /&gt;
  public void actionPerformed(ActionEvent e) {&lt;br /&gt;
    dispose();&lt;br /&gt;
    System.exit(0);&lt;br /&gt;
  }&lt;br /&gt;
  public SimpleLOD() {&lt;br /&gt;
    VirtualUniverse myUniverse = new VirtualUniverse();&lt;br /&gt;
    Locale myLocale = new Locale(myUniverse);&lt;br /&gt;
    myLocale.addBranchGraph(buildViewBranch(myCanvas3D));&lt;br /&gt;
    myLocale.addBranchGraph(buildContentBranch());&lt;br /&gt;
    setTitle(&amp;quot;SimpleLOD&amp;quot;);&lt;br /&gt;
    setSize(400, 400);&lt;br /&gt;
    setLayout(new BorderLayout());&lt;br /&gt;
    Panel bottom = new Panel();&lt;br /&gt;
    bottom.add(exitButton);&lt;br /&gt;
    add(BorderLayout.CENTER, myCanvas3D);&lt;br /&gt;
    add(BorderLayout.SOUTH, bottom);&lt;br /&gt;
    exitButton.addActionListener(this);&lt;br /&gt;
    setVisible(true);&lt;br /&gt;
  }&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    SimpleLOD sl = new SimpleLOD();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>