001: /*
002: * $RCSfile: GeometryStripArray.java,v $
003: *
004: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.6 $
028: * $Date: 2008/02/28 20:17:22 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * The GeometryStripArray object is an abstract class that is extended for
036: * a set of GeometryArray strip primitives. These include LINE_STRIP,
037: * TRIANGLE_STRIP, and TRIANGLE_FAN. In addition to specifying the array
038: * of vertex elements, which is inherited from GeometryArray, the
039: * GeometryStripArray class specifies the number of strips and an
040: * array of per-strip vertex counts that specify where the separate strips
041: * appear in the vertex array.
042: */
043:
044: public abstract class GeometryStripArray extends GeometryArray {
045:
046: // non-public, no parameter constructor
047: GeometryStripArray() {
048: }
049:
050: /**
051: * Constructs an empty GeometryStripArray object with the specified
052: * number of vertices, vertex format, and
053: * array of per-strip vertex counts.
054: *
055: * @param vertexCount
056: * see {@link GeometryArray#GeometryArray(int,int)}
057: * for a description of this parameter.
058: *
059: * @param vertexFormat
060: * see {@link GeometryArray#GeometryArray(int,int)}
061: * for a description of this parameter.
062: *
063: * @param stripVertexCounts array that specifies
064: * the count of the number of vertices for each separate strip.
065: * The length of this array is the number of separate strips.
066: * The sum of the elements in this array defines the total number
067: * of valid vertices that are rendered (validVertexCount).
068: *
069: * @exception IllegalArgumentException if
070: * <code>validVertexCount > vertexCount</code>
071: * ;<br>
072: * See {@link GeometryArray#GeometryArray(int,int)}
073: * for more exceptions that can be thrown
074: */
075: public GeometryStripArray(int vertexCount, int vertexFormat,
076: int[] stripVertexCounts) {
077:
078: super (vertexCount, vertexFormat);
079: ((GeometryStripArrayRetained) this .retained)
080: .setStripVertexCounts(stripVertexCounts);
081: }
082:
083: /**
084: * Constructs an empty GeometryStripArray object with the specified
085: * number of vertices, vertex format, number of texture coordinate
086: * sets, texture coordinate mapping array, and
087: * array of per-strip vertex counts.
088: *
089: * @param vertexCount
090: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
091: * for a description of this parameter.
092: *
093: * @param vertexFormat
094: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
095: * for a description of this parameter.
096: *
097: * @param texCoordSetCount
098: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
099: * for a description of this parameter.
100: *
101: * @param texCoordSetMap
102: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
103: * for a description of this parameter.
104: *
105: * @param stripVertexCounts array that specifies
106: * the count of the number of vertices for each separate strip.
107: * The length of this array is the number of separate strips.
108: * The sum of the elements in this array defines the total number
109: * of valid vertices that are rendered (validVertexCount).
110: *
111: * @exception IllegalArgumentException if
112: * <code>validVertexCount > vertexCount</code>
113: * ;<br>
114: * See {@link GeometryArray#GeometryArray(int,int,int,int[])}
115: * for more exceptions that can be thrown
116: *
117: * @since Java 3D 1.2
118: */
119: public GeometryStripArray(int vertexCount, int vertexFormat,
120: int texCoordSetCount, int[] texCoordSetMap,
121: int[] stripVertexCounts) {
122:
123: super (vertexCount, vertexFormat, texCoordSetCount,
124: texCoordSetMap);
125: ((GeometryStripArrayRetained) this .retained)
126: .setStripVertexCounts(stripVertexCounts);
127: }
128:
129: /**
130: * Constructs an empty GeometryStripArray object with the
131: * specified number of vertices, vertex format, number of texture
132: * coordinate sets, texture coordinate mapping array, vertex
133: * attribute count, vertex attribute sizes array, and array of
134: * per-strip vertex counts.
135: *
136: * @param vertexCount
137: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
138: * for a description of this parameter.
139: *
140: * @param vertexFormat
141: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
142: * for a description of this parameter.
143: *
144: * @param texCoordSetMap
145: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
146: * for a description of this parameter.
147: *
148: * @param vertexAttrCount
149: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
150: * for a description of this parameter.
151: *
152: * @param vertexAttrSizes
153: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
154: * for a description of this parameter.
155: *
156: * @param stripVertexCounts array that specifies
157: * the count of the number of vertices for each separate strip.
158: * The length of this array is the number of separate strips.
159: * The sum of the elements in this array defines the total number
160: * of valid vertices that are rendered (validVertexCount).
161: *
162: * @exception IllegalArgumentException if
163: * <code>validVertexCount > vertexCount</code>
164: * ;<br>
165: * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
166: * for more exceptions that can be thrown
167: *
168: * @since Java 3D 1.4
169: */
170: public GeometryStripArray(int vertexCount, int vertexFormat,
171: int texCoordSetCount, int[] texCoordSetMap,
172: int vertexAttrCount, int[] vertexAttrSizes,
173: int[] stripVertexCounts) {
174:
175: super (vertexCount, vertexFormat, texCoordSetCount,
176: texCoordSetMap, vertexAttrCount, vertexAttrSizes);
177:
178: ((GeometryStripArrayRetained) this .retained)
179: .setStripVertexCounts(stripVertexCounts);
180: }
181:
182: /**
183: * Get number of strips in the GeometryStripArray.
184: * @return numStrips number of strips
185: */
186: public int getNumStrips() {
187: if (isLiveOrCompiled())
188: if (!this .getCapability(GeometryArray.ALLOW_COUNT_READ))
189: throw new CapabilityNotSetException(J3dI18N
190: .getString("GeometryStripArray0"));
191:
192: return ((GeometryStripArrayRetained) this .retained)
193: .getNumStrips();
194: }
195:
196: /**
197: * Sets the array of strip vertex counts. The length of this
198: * array is the number of separate strips. The elements in this
199: * array specify the number of vertices for each separate strip.
200: * The sum of the elements in this array defines the total number
201: * of valid vertices that are rendered (validVertexCount).
202: *
203: * @param stripVertexCounts array that specifies
204: * the count of the number of vertices for each separate strip.
205: *
206: * @exception IllegalArgumentException if any of the following are
207: * true:
208: * <ul>
209: * <code>initialVertexIndex + validVertexCount > vertexCount</code>,<br>
210: * <code>initialCoordIndex + validVertexCount > vertexCount</code>,<br>
211: * <code>initialColorIndex + validVertexCount > vertexCount</code>,<br>
212: * <code>initialNormalIndex + validVertexCount > vertexCount</code>,<br>
213: * <code>initialTexCoordIndex + validVertexCount > vertexCount</code>
214: * </ul>
215: * <p>
216: *
217: * @exception ArrayIndexOutOfBoundsException if the geometry data format
218: * is <code>BY_REFERENCE</code> and any the following
219: * are true for non-null array references:
220: * <ul>
221: * <code>CoordRef.length</code> < <i>num_words</i> *
222: * (<code>initialCoordIndex + validVertexCount</code>)<br>
223: * <code>ColorRef.length</code> < <i>num_words</i> *
224: * (<code>initialColorIndex + validVertexCount</code>)<br>
225: * <code>NormalRef.length</code> < <i>num_words</i> *
226: * (<code>initialNormalIndex + validVertexCount</code>)<br>
227: * <code>TexCoordRef.length</code> < <i>num_words</i> *
228: * (<code>initialTexCoordIndex + validVertexCount</code>)<br>
229: * </ul>
230: * where <i>num_words</i> depends on which variant of
231: * <code>set</code><i>Array</i><code>Ref</code> is used.
232: *
233: * @since Java 3D 1.3
234: */
235: public void setStripVertexCounts(int[] stripVertexCounts) {
236: if (isLiveOrCompiled())
237: if (!this .getCapability(GeometryArray.ALLOW_COUNT_WRITE))
238: throw new CapabilityNotSetException(J3dI18N
239: .getString("GeometryStripArray2"));
240:
241: ((GeometryStripArrayRetained) this .retained)
242: .setStripVertexCounts(stripVertexCounts);
243:
244: }
245:
246: /**
247: * Get a list of vertexCounts for each strip. The list is copied
248: * into the specified array. The array must be large enough to hold
249: * all of the ints.
250: * @param stripVertexCounts an array that will receive vertexCounts
251: */
252: public void getStripVertexCounts(int[] stripVertexCounts) {
253: if (isLiveOrCompiled())
254: if (!this .getCapability(GeometryArray.ALLOW_COUNT_READ))
255: throw new CapabilityNotSetException(J3dI18N
256: .getString("GeometryStripArray1"));
257:
258: ((GeometryStripArrayRetained) this .retained)
259: .getStripVertexCounts(stripVertexCounts);
260: }
261:
262: /**
263: * This method is not supported for geometry strip arrays.
264: * The sum of the elements in the strip vertex counts array
265: * defines the valid vertex count.
266: *
267: * @exception UnsupportedOperationException this method is not supported
268: *
269: * @since Java 3D 1.3
270: */
271: public void setValidVertexCount(int validVertexCount) {
272: throw new UnsupportedOperationException();
273: }
274:
275: }
|