samer@1: /* samer@1: * Axis.java 1.0 98/11/25 samer@1: * samer@1: * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved. samer@1: * samer@1: * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, samer@1: * modify and redistribute this software in source and binary code form, samer@1: * provided that i) this copyright notice and license appear on all copies of samer@1: * the software; and ii) Licensee does not utilize the software in a manner samer@1: * which is disparaging to Sun. samer@1: * samer@1: * This software is provided "AS IS," without a warranty of any kind. ALL samer@1: * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY samer@1: * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR samer@1: * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE samer@1: * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING samer@1: * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS samer@1: * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, samer@1: * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER samer@1: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF samer@1: * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE samer@1: * POSSIBILITY OF SUCH DAMAGES. samer@1: * samer@1: * This software is not designed or intended for use in on-line control of samer@1: * aircraft, air traffic, aircraft navigation or aircraft communications; or in samer@1: * the design, construction, operation or maintenance of any nuclear samer@1: * facility. Licensee represents and warrants that it will not use or samer@1: * redistribute the Software for such purposes. samer@1: */ samer@1: samer@1: /* samer@1: * Getting Started with the Java 3D API samer@1: * written in Java 3D samer@1: * samer@1: * This program demonstrates: samer@1: * 1. writing a visual object class samer@1: * In this program, Axis class defines a visual object samer@1: * This particular class extends Shape3D samer@1: * See the text for a discussion. samer@1: * 2. Using LineArray to draw 3D lines. samer@1: */ samer@1: samer@1: samer@1: import javax.media.j3d.*; samer@1: import javax.vecmath.*; samer@1: samer@1: samer@1: public class Axis extends Shape3D{ samer@1: samer@1: //////////////////////////////////////////// samer@1: // samer@1: // create axis visual object samer@1: // samer@1: public Axis() { samer@1: samer@1: this.setGeometry(createGeometry()); samer@1: samer@1: } samer@1: samer@1: private Geometry createGeometry(){ samer@1: // create line for X axis samer@1: IndexedLineArray axisLines = new IndexedLineArray(18, GeometryArray.COORDINATES, 30); samer@1: samer@1: axisLines.setCoordinate( 0, new Point3f(-1.0f, 0.0f, 0.0f)); samer@1: axisLines.setCoordinate( 1, new Point3f( 1.0f, 0.0f, 0.0f)); samer@1: axisLines.setCoordinate( 2, new Point3f( 0.9f, 0.1f, 0.1f)); samer@1: axisLines.setCoordinate( 3, new Point3f( 0.9f,-0.1f, 0.1f)); samer@1: axisLines.setCoordinate( 4, new Point3f( 0.9f, 0.1f,-0.1f)); samer@1: axisLines.setCoordinate( 5, new Point3f( 0.9f,-0.1f,-0.1f)); samer@1: axisLines.setCoordinate( 6, new Point3f( 0.0f,-1.0f, 0.0f)); samer@1: axisLines.setCoordinate( 7, new Point3f( 0.0f, 1.0f, 0.0f)); samer@1: axisLines.setCoordinate( 8, new Point3f( 0.1f, 0.9f, 0.1f)); samer@1: axisLines.setCoordinate( 9, new Point3f(-0.1f, 0.9f, 0.1f)); samer@1: axisLines.setCoordinate(10, new Point3f( 0.1f, 0.9f,-0.1f)); samer@1: axisLines.setCoordinate(11, new Point3f(-0.1f, 0.9f,-0.1f)); samer@1: axisLines.setCoordinate(12, new Point3f( 0.0f, 0.0f,-1.0f)); samer@1: axisLines.setCoordinate(13, new Point3f( 0.0f, 0.0f, 1.0f)); samer@1: axisLines.setCoordinate(14, new Point3f( 0.1f, 0.1f, 0.9f)); samer@1: axisLines.setCoordinate(15, new Point3f(-0.1f, 0.1f, 0.9f)); samer@1: axisLines.setCoordinate(16, new Point3f( 0.1f,-0.1f, 0.9f)); samer@1: axisLines.setCoordinate(17, new Point3f(-0.1f,-0.1f, 0.9f)); samer@1: samer@1: axisLines.setCoordinateIndex( 0, 0); samer@1: axisLines.setCoordinateIndex( 1, 1); samer@1: axisLines.setCoordinateIndex( 2, 2); samer@1: axisLines.setCoordinateIndex( 3, 1); samer@1: axisLines.setCoordinateIndex( 4, 3); samer@1: axisLines.setCoordinateIndex( 5, 1); samer@1: axisLines.setCoordinateIndex( 6, 4); samer@1: axisLines.setCoordinateIndex( 7, 1); samer@1: axisLines.setCoordinateIndex( 8, 5); samer@1: axisLines.setCoordinateIndex( 9, 1); samer@1: axisLines.setCoordinateIndex(10, 6); samer@1: axisLines.setCoordinateIndex(11, 7); samer@1: axisLines.setCoordinateIndex(12, 8); samer@1: axisLines.setCoordinateIndex(13, 7); samer@1: axisLines.setCoordinateIndex(14, 9); samer@1: axisLines.setCoordinateIndex(15, 7); samer@1: axisLines.setCoordinateIndex(16,10); samer@1: axisLines.setCoordinateIndex(17, 7); samer@1: axisLines.setCoordinateIndex(18,11); samer@1: axisLines.setCoordinateIndex(19, 7); samer@1: axisLines.setCoordinateIndex(20,12); samer@1: axisLines.setCoordinateIndex(21,13); samer@1: axisLines.setCoordinateIndex(22,14); samer@1: axisLines.setCoordinateIndex(23,13); samer@1: axisLines.setCoordinateIndex(24,15); samer@1: axisLines.setCoordinateIndex(25,13); samer@1: axisLines.setCoordinateIndex(26,16); samer@1: axisLines.setCoordinateIndex(27,13); samer@1: axisLines.setCoordinateIndex(28,17); samer@1: axisLines.setCoordinateIndex(29,13); samer@1: samer@1: return axisLines; samer@1: samer@1: } // end of Axis createGeometry() samer@1: samer@1: samer@1: } // end of class Axis