001: /*
002: * $RCSfile: IndexedQuadArray.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:24 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * The IndexedQuadArray object draws the array of vertices as individual
036: * quadrilaterals. Each group
037: * of four vertices defines a quadrilateral to be drawn.
038: */
039:
040: public class IndexedQuadArray extends IndexedGeometryArray {
041:
042: /**
043: * Package scoped default constructor.
044: */
045: IndexedQuadArray() {
046: }
047:
048: /**
049: * Constructs an empty IndexedQuadArray object using the specified
050: * parameters.
051: *
052: * @param vertexCount
053: * see {@link GeometryArray#GeometryArray(int,int)}
054: * for a description of this parameter.
055: *
056: * @param vertexFormat
057: * see {@link GeometryArray#GeometryArray(int,int)}
058: * for a description of this parameter.
059: *
060: * @param indexCount
061: * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)}
062: * for a description of this parameter.
063: *
064: * @exception IllegalArgumentException if vertexCount is less than 1,
065: * or indexCount is less than 4, or indexCount is <i>not</i>
066: * a multiple of 4
067: * ;<br>
068: * See {@link GeometryArray#GeometryArray(int,int)}
069: * for more exceptions that can be thrown
070: */
071: public IndexedQuadArray(int vertexCount, int vertexFormat,
072: int indexCount) {
073: super (vertexCount, vertexFormat, indexCount);
074:
075: if (vertexCount < 1)
076: throw new IllegalArgumentException(J3dI18N
077: .getString("IndexedQuadArray0"));
078:
079: if (indexCount < 4 || ((indexCount % 4) != 0))
080: throw new IllegalArgumentException(J3dI18N
081: .getString("IndexedQuadArray1"));
082: }
083:
084: /**
085: * Constructs an empty IndexedQuadArray object using the specified
086: * parameters.
087: *
088: * @param vertexCount
089: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
090: * for a description of this parameter.
091: *
092: * @param vertexFormat
093: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
094: * for a description of this parameter.
095: *
096: * @param texCoordSetCount
097: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
098: * for a description of this parameter.
099: *
100: * @param texCoordSetMap
101: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
102: * for a description of this parameter.
103: *
104: * @param indexCount
105: * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)}
106: * for a description of this parameter.
107: *
108: * @exception IllegalArgumentException if vertexCount is less than 1,
109: * or indexCount is less than 4, or indexCount is <i>not</i>
110: * a multiple of 4
111: * ;<br>
112: * See {@link GeometryArray#GeometryArray(int,int,int,int[])}
113: * for more exceptions that can be thrown
114: *
115: * @since Java 3D 1.2
116: */
117: public IndexedQuadArray(int vertexCount, int vertexFormat,
118: int texCoordSetCount, int[] texCoordSetMap, int indexCount) {
119:
120: super (vertexCount, vertexFormat, texCoordSetCount,
121: texCoordSetMap, indexCount);
122:
123: if (vertexCount < 1)
124: throw new IllegalArgumentException(J3dI18N
125: .getString("IndexedQuadArray0"));
126:
127: if (indexCount < 4 || ((indexCount % 4) != 0))
128: throw new IllegalArgumentException(J3dI18N
129: .getString("IndexedQuadArray1"));
130: }
131:
132: /**
133: * Constructs an empty IndexedQuadArray object using the specified
134: * parameters.
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 indexCount
157: * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)}
158: * for a description of this parameter.
159: *
160: * @exception IllegalArgumentException if vertexCount is less than 1,
161: * or indexCount is less than 4, or indexCount is <i>not</i>
162: * a multiple of 4
163: * ;<br>
164: * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
165: * for more exceptions that can be thrown
166: *
167: * @since Java 3D 1.4
168: */
169: public IndexedQuadArray(int vertexCount, int vertexFormat,
170: int texCoordSetCount, int[] texCoordSetMap,
171: int vertexAttrCount, int[] vertexAttrSizes, int indexCount) {
172:
173: super (vertexCount, vertexFormat, texCoordSetCount,
174: texCoordSetMap, vertexAttrCount, vertexAttrSizes,
175: indexCount);
176:
177: if (vertexCount < 1)
178: throw new IllegalArgumentException(J3dI18N
179: .getString("IndexedQuadArray0"));
180:
181: if (indexCount < 4 || ((indexCount % 4) != 0))
182: throw new IllegalArgumentException(J3dI18N
183: .getString("IndexedQuadArray1"));
184: }
185:
186: /**
187: * Creates the retained mode IndexedQuadArrayRetained object that this
188: * IndexedQuadArray object will point to.
189: */
190: void createRetained() {
191: this .retained = new IndexedQuadArrayRetained();
192: this .retained.setSource(this );
193: }
194:
195: /**
196: * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
197: */
198: public NodeComponent cloneNodeComponent() {
199: IndexedQuadArrayRetained rt = (IndexedQuadArrayRetained) retained;
200: int texSetCount = rt.getTexCoordSetCount();
201: int[] texMap = null;
202: int vertexAttrCount = rt.getVertexAttrCount();
203: int[] vertexAttrSizes = null;
204: if (texSetCount > 0) {
205: texMap = new int[rt.getTexCoordSetMapLength()];
206: rt.getTexCoordSetMap(texMap);
207: }
208: if (vertexAttrCount > 0) {
209: vertexAttrSizes = new int[vertexAttrCount];
210: rt.getVertexAttrSizes(vertexAttrSizes);
211: }
212: IndexedQuadArray q = new IndexedQuadArray(rt.getVertexCount(),
213: rt.getVertexFormat(), texSetCount, texMap,
214: vertexAttrCount, vertexAttrSizes, rt.getIndexCount());
215: q.duplicateNodeComponent(this);
216: return q;
217: }
218: }
|