001: /*
002: * $RCSfile: IcosahedronTSA.java,v $
003: *
004: * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Redistribution and use in source and binary forms, with or without
007: * modification, are permitted provided that the following conditions
008: * are met:
009: *
010: * - Redistribution of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * - Redistribution in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in
015: * the documentation and/or other materials provided with the
016: * distribution.
017: *
018: * Neither the name of Sun Microsystems, Inc. or the names of
019: * contributors may be used to endorse or promote products derived
020: * from this software without specific prior written permission.
021: *
022: * This software is provided "AS IS," without a warranty of any
023: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
024: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
025: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
026: * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
027: * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
028: * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
029: * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
030: * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
031: * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
032: * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
033: * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
034: * POSSIBILITY OF SUCH DAMAGES.
035: *
036: * You acknowledge that this software is not designed, licensed or
037: * intended for use in the design, construction, operation or
038: * maintenance of any nuclear facility.
039: *
040: * $Revision: 1.2 $
041: * $Date: 2007/02/09 17:21:47 $
042: * $State: Exp $
043: */
044:
045: package org.jdesktop.j3d.examples.picking;
046:
047: import javax.media.j3d.*;
048: import javax.vecmath.*;
049:
050: class IcosahedronTSA extends TriangleStripArray {
051: private static final int[] sVertCnt = { 3, 11, 5, 4, 5, 4 };
052:
053: IcosahedronTSA() {
054: super (32, GeometryArray.COORDINATES | GeometryArray.COLOR_3,
055: sVertCnt);
056:
057: Point3f verts[] = new Point3f[12];
058: Color3f colors[] = new Color3f[12];
059:
060: verts[0] = new Point3f(0.0f, 1.4f, 0.8652f);
061: verts[1] = new Point3f(0.0f, 1.4f, -0.8652f);
062: verts[2] = new Point3f(1.4f, 0.8652f, 0.0f);
063: verts[3] = new Point3f(1.4f, -0.8652f, 0.0f);
064: verts[4] = new Point3f(0.0f, -1.4f, -0.8652f);
065: verts[5] = new Point3f(0.0f, -1.4f, 0.8652f);
066: verts[6] = new Point3f(0.8652f, 0.0f, 1.4f);
067: verts[7] = new Point3f(-0.8652f, 0.0f, 1.4f);
068: verts[8] = new Point3f(0.8652f, 0.0f, -1.4f);
069: verts[9] = new Point3f(-0.8652f, 0.0f, -1.4f);
070: verts[10] = new Point3f(-1.4f, 0.8652f, 0.0f);
071: verts[11] = new Point3f(-1.4f, -0.8652f, 0.0f);
072:
073: colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
074: colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
075: colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
076: colors[3] = new Color3f(1.0f, 1.0f, 0.0f);
077: colors[4] = new Color3f(0.0f, 1.0f, 1.0f);
078: colors[5] = new Color3f(1.0f, 0.0f, 1.0f);
079: colors[6] = new Color3f(0.0f, 0.5f, 0.0f);
080: colors[7] = new Color3f(0.0f, 0.0f, 0.5f);
081: colors[8] = new Color3f(0.5f, 0.5f, 0.0f);
082: colors[9] = new Color3f(0.0f, 0.5f, 0.5f);
083: colors[10] = new Color3f(0.5f, 0.0f, 0.5f);
084: colors[11] = new Color3f(0.5f, 0.5f, 0.5f);
085:
086: Point3f pnts[] = new Point3f[32];
087: Color3f clrs[] = new Color3f[32];
088:
089: pnts[0] = verts[4];
090: clrs[0] = colors[4];
091: pnts[1] = verts[5];
092: clrs[1] = colors[5];
093: pnts[2] = verts[11];
094: clrs[2] = colors[11];
095:
096: pnts[3] = verts[11];
097: clrs[3] = colors[11];
098: pnts[4] = verts[5];
099: clrs[4] = colors[5];
100: pnts[5] = verts[7];
101: clrs[5] = colors[7];
102:
103: pnts[6] = verts[6];
104: clrs[6] = colors[6];
105:
106: pnts[7] = verts[0];
107: clrs[7] = colors[0];
108:
109: pnts[8] = verts[2];
110: clrs[8] = colors[2];
111:
112: pnts[9] = verts[1];
113: clrs[9] = colors[1];
114:
115: pnts[10] = verts[8];
116: clrs[10] = colors[8];
117:
118: pnts[11] = verts[9];
119: clrs[11] = colors[9];
120:
121: pnts[12] = verts[4];
122: clrs[12] = colors[4];
123:
124: pnts[13] = verts[11];
125: clrs[13] = colors[11];
126:
127: pnts[14] = verts[2];
128: clrs[14] = colors[2];
129: pnts[15] = verts[6];
130: clrs[15] = colors[6];
131: pnts[16] = verts[3];
132: clrs[16] = colors[3];
133:
134: pnts[17] = verts[5];
135: clrs[17] = colors[5];
136:
137: pnts[18] = verts[4];
138: clrs[18] = colors[4];
139:
140: pnts[19] = verts[4];
141: clrs[19] = colors[4];
142: pnts[20] = verts[8];
143: clrs[20] = colors[8];
144: pnts[21] = verts[3];
145: clrs[21] = colors[3];
146:
147: pnts[22] = verts[2];
148: clrs[22] = colors[2];
149:
150: pnts[23] = verts[0];
151: clrs[23] = colors[0];
152: pnts[24] = verts[1];
153: clrs[24] = colors[1];
154: pnts[25] = verts[10];
155: clrs[25] = colors[10];
156:
157: pnts[26] = verts[9];
158: clrs[26] = colors[9];
159:
160: pnts[27] = verts[11];
161: clrs[27] = colors[11];
162:
163: pnts[28] = verts[0];
164: clrs[28] = colors[0];
165: pnts[29] = verts[10];
166: clrs[29] = colors[10];
167: pnts[30] = verts[7];
168: clrs[30] = colors[7];
169:
170: pnts[31] = verts[11];
171: clrs[31] = colors[11];
172:
173: setCoordinates(0, pnts);
174: setColors(0, clrs);
175: }
176: }
|