comparison examples/java3d/Axis.java @ 1:5df24c91468d

Oh my what a mess.
author samer
date Fri, 05 Apr 2019 16:26:00 +0100
parents
children
comparison
equal deleted inserted replaced
0:bf79fb79ee13 1:5df24c91468d
1 /*
2 * Axis.java 1.0 98/11/25
3 *
4 * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
5 *
6 * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
7 * modify and redistribute this software in source and binary code form,
8 * provided that i) this copyright notice and license appear on all copies of
9 * the software; and ii) Licensee does not utilize the software in a manner
10 * which is disparaging to Sun.
11 *
12 * This software is provided "AS IS," without a warranty of any kind. ALL
13 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
14 * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
15 * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
16 * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
17 * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
18 * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
19 * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
20 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
21 * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
22 * POSSIBILITY OF SUCH DAMAGES.
23 *
24 * This software is not designed or intended for use in on-line control of
25 * aircraft, air traffic, aircraft navigation or aircraft communications; or in
26 * the design, construction, operation or maintenance of any nuclear
27 * facility. Licensee represents and warrants that it will not use or
28 * redistribute the Software for such purposes.
29 */
30
31 /*
32 * Getting Started with the Java 3D API
33 * written in Java 3D
34 *
35 * This program demonstrates:
36 * 1. writing a visual object class
37 * In this program, Axis class defines a visual object
38 * This particular class extends Shape3D
39 * See the text for a discussion.
40 * 2. Using LineArray to draw 3D lines.
41 */
42
43
44 import javax.media.j3d.*;
45 import javax.vecmath.*;
46
47
48 public class Axis extends Shape3D{
49
50 ////////////////////////////////////////////
51 //
52 // create axis visual object
53 //
54 public Axis() {
55
56 this.setGeometry(createGeometry());
57
58 }
59
60 private Geometry createGeometry(){
61 // create line for X axis
62 IndexedLineArray axisLines = new IndexedLineArray(18, GeometryArray.COORDINATES, 30);
63
64 axisLines.setCoordinate( 0, new Point3f(-1.0f, 0.0f, 0.0f));
65 axisLines.setCoordinate( 1, new Point3f( 1.0f, 0.0f, 0.0f));
66 axisLines.setCoordinate( 2, new Point3f( 0.9f, 0.1f, 0.1f));
67 axisLines.setCoordinate( 3, new Point3f( 0.9f,-0.1f, 0.1f));
68 axisLines.setCoordinate( 4, new Point3f( 0.9f, 0.1f,-0.1f));
69 axisLines.setCoordinate( 5, new Point3f( 0.9f,-0.1f,-0.1f));
70 axisLines.setCoordinate( 6, new Point3f( 0.0f,-1.0f, 0.0f));
71 axisLines.setCoordinate( 7, new Point3f( 0.0f, 1.0f, 0.0f));
72 axisLines.setCoordinate( 8, new Point3f( 0.1f, 0.9f, 0.1f));
73 axisLines.setCoordinate( 9, new Point3f(-0.1f, 0.9f, 0.1f));
74 axisLines.setCoordinate(10, new Point3f( 0.1f, 0.9f,-0.1f));
75 axisLines.setCoordinate(11, new Point3f(-0.1f, 0.9f,-0.1f));
76 axisLines.setCoordinate(12, new Point3f( 0.0f, 0.0f,-1.0f));
77 axisLines.setCoordinate(13, new Point3f( 0.0f, 0.0f, 1.0f));
78 axisLines.setCoordinate(14, new Point3f( 0.1f, 0.1f, 0.9f));
79 axisLines.setCoordinate(15, new Point3f(-0.1f, 0.1f, 0.9f));
80 axisLines.setCoordinate(16, new Point3f( 0.1f,-0.1f, 0.9f));
81 axisLines.setCoordinate(17, new Point3f(-0.1f,-0.1f, 0.9f));
82
83 axisLines.setCoordinateIndex( 0, 0);
84 axisLines.setCoordinateIndex( 1, 1);
85 axisLines.setCoordinateIndex( 2, 2);
86 axisLines.setCoordinateIndex( 3, 1);
87 axisLines.setCoordinateIndex( 4, 3);
88 axisLines.setCoordinateIndex( 5, 1);
89 axisLines.setCoordinateIndex( 6, 4);
90 axisLines.setCoordinateIndex( 7, 1);
91 axisLines.setCoordinateIndex( 8, 5);
92 axisLines.setCoordinateIndex( 9, 1);
93 axisLines.setCoordinateIndex(10, 6);
94 axisLines.setCoordinateIndex(11, 7);
95 axisLines.setCoordinateIndex(12, 8);
96 axisLines.setCoordinateIndex(13, 7);
97 axisLines.setCoordinateIndex(14, 9);
98 axisLines.setCoordinateIndex(15, 7);
99 axisLines.setCoordinateIndex(16,10);
100 axisLines.setCoordinateIndex(17, 7);
101 axisLines.setCoordinateIndex(18,11);
102 axisLines.setCoordinateIndex(19, 7);
103 axisLines.setCoordinateIndex(20,12);
104 axisLines.setCoordinateIndex(21,13);
105 axisLines.setCoordinateIndex(22,14);
106 axisLines.setCoordinateIndex(23,13);
107 axisLines.setCoordinateIndex(24,15);
108 axisLines.setCoordinateIndex(25,13);
109 axisLines.setCoordinateIndex(26,16);
110 axisLines.setCoordinateIndex(27,13);
111 axisLines.setCoordinateIndex(28,17);
112 axisLines.setCoordinateIndex(29,13);
113
114 return axisLines;
115
116 } // end of Axis createGeometry()
117
118
119 } // end of class Axis