📄 indexedgeometryarray.java
字号:
/* * $RCSfile: IndexedGeometryArray.java,v $ * * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.6 $ * $Date: 2007/02/09 17:18:03 $ * $State: Exp $ */package javax.media.j3d;import javax.vecmath.*;/** * The IndexedGeometryArray object contains separate integer arrays * that index into the arrays of positional coordinates, colors, * normals, texture coordinates, and vertex attributes. * These index arrays specify how * vertices are connected to form geometry primitives. This class is * extended to create the various indexed primitive types (e.g., * lines, triangle strips, etc.). */public abstract class IndexedGeometryArray extends GeometryArray { // non-public, no parameter constructor IndexedGeometryArray() { // set default read capabilities setDefaultReadCapabilities(readCapabilities); } /** * Specifies that this IndexedGeometryArray allows reading the array of * coordinate indices. */ public static final int ALLOW_COORDINATE_INDEX_READ = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_COORDINATE_INDEX_READ; /** * Specifies that this IndexedGeometryArray allows writing the array of * coordinate indices. */ public static final int ALLOW_COORDINATE_INDEX_WRITE = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_COORDINATE_INDEX_WRITE; /** * Specifies that this IndexedGeometryArray allows reading the array of * color indices. */ public static final int ALLOW_COLOR_INDEX_READ = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_COLOR_INDEX_READ; /** * Specifies that this IndexedGeometryArray allows writing the array of * color indices. */ public static final int ALLOW_COLOR_INDEX_WRITE = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_COLOR_INDEX_WRITE; /** * Specifies that this IndexedGeometryArray allows reading the array of * normal indices. */ public static final int ALLOW_NORMAL_INDEX_READ = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_NORMAL_INDEX_READ; /** * Specifies that this IndexedGeometryArray allows writing the array of * normal indices. */ public static final int ALLOW_NORMAL_INDEX_WRITE = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_NORMAL_INDEX_WRITE; /** * Specifies that this IndexedGeometryArray allows reading the array of * texture coordinate indices. */ public static final int ALLOW_TEXCOORD_INDEX_READ = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_TEXCOORD_INDEX_READ; /** * Specifies that this IndexedGeometryArray allows writing the array of * texture coordinate indices. */ public static final int ALLOW_TEXCOORD_INDEX_WRITE = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_TEXCOORD_INDEX_WRITE; /** * Specifies that this IndexedGeometryArray allows reading the array of * vertex attribute indices. * * @since Java 3D 1.4 */ public static final int ALLOW_VERTEX_ATTR_INDEX_READ = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_INDEX_READ; /** * Specifies that this IndexedGeometryArray allows writing the array of * vertex attribute indices. * * @since Java 3D 1.4 */ public static final int ALLOW_VERTEX_ATTR_INDEX_WRITE = CapabilityBits.INDEXED_GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_INDEX_WRITE; // Array for setting default read capabilities private static final int[] readCapabilities = { ALLOW_COLOR_INDEX_READ, ALLOW_COORDINATE_INDEX_READ, ALLOW_NORMAL_INDEX_READ, ALLOW_TEXCOORD_INDEX_READ, ALLOW_VERTEX_ATTR_INDEX_READ }; /** * Constructs an empty IndexedGeometryArray object with the specified * number of vertices, vertex format, and number of indices. * Defaults are used for all other parameters. The default values * are as follows: * * <ul> * validIndexCount : indexCount<br> * initialIndexIndex : 0<br> * all index array values : 0<br> * </ul> * * @param vertexCount * see {@link GeometryArray#GeometryArray(int,int)} * for a description of this parameter. * * @param vertexFormat * see {@link GeometryArray#GeometryArray(int,int)} * for a description of this parameter. * * @param indexCount the number of indices in this object. This * count is the maximum number of vertices that will be rendered. * * @exception IllegalArgumentException if <code>indexCount < 0</code> * ;<br> * See {@link GeometryArray#GeometryArray(int,int)} * for more exceptions that can be thrown */ public IndexedGeometryArray(int vertexCount, int vertexFormat, int indexCount) { super(vertexCount, vertexFormat); // set default read capabilities setDefaultReadCapabilities(readCapabilities); ((IndexedGeometryArrayRetained)this.retained).createIndexedGeometryArrayData(indexCount); } /** * Constructs an empty IndexedGeometryArray object with the specified * number of vertices, vertex format, number of texture coordinate * sets, texture coordinate mapping array, and number of indices. * Defaults are used for all other parameters. * * @param vertexCount * see {@link GeometryArray#GeometryArray(int,int,int,int[])} * for a description of this parameter. * * @param vertexFormat * see {@link GeometryArray#GeometryArray(int,int,int,int[])} * for a description of this parameter. * * @param texCoordSetCount * see {@link GeometryArray#GeometryArray(int,int,int,int[])} * for a description of this parameter. * * @param texCoordSetMap * see {@link GeometryArray#GeometryArray(int,int,int,int[])} * for a description of this parameter. * * @param indexCount the number of indices in this object. This * count is the maximum number of vertices that will be rendered. * * @exception IllegalArgumentException if <code>indexCount < 0</code> * ;<br> * See {@link GeometryArray#GeometryArray(int,int,int,int[])} * for more exceptions that can be thrown * * @since Java 3D 1.2 */ public IndexedGeometryArray(int vertexCount, int vertexFormat, int texCoordSetCount, int[] texCoordSetMap, int indexCount) { this(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, 0, null, indexCount); } /** * Constructs an empty IndexedGeometryArray object with the * specified number of vertices, vertex format, number of texture * coordinate sets, texture coordinate mapping array, vertex * attribute count, vertex attribute sizes array, and number of * indices. * * @param vertexCount * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} * for a description of this parameter. * * @param vertexFormat * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} * for a description of this parameter. * * @param texCoordSetMap * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} * for a description of this parameter. * * @param vertexAttrCount * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} * for a description of this parameter. * * @param vertexAttrSizes * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} * for a description of this parameter. * * @param indexCount the number of indices in this object. This * count is the maximum number of vertices that will be rendered. * * @exception IllegalArgumentException if <code>indexCount < 0</code> * ;<br> * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])} * for more exceptions that can be thrown * * @since Java 3D 1.4 */ public IndexedGeometryArray(int vertexCount, int vertexFormat, int texCoordSetCount, int[] texCoordSetMap, int vertexAttrCount, int[] vertexAttrSizes, int indexCount) { super(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, vertexAttrCount, vertexAttrSizes); // set default read capabilities setDefaultReadCapabilities(readCapabilities); ((IndexedGeometryArrayRetained)this.retained).createIndexedGeometryArrayData(indexCount); } /** * Gets number of indices for this IndexedGeometryArray. * @return indexCount the number of indices */ public int getIndexCount(){ if (isLiveOrCompiled()) if(!this.getCapability(GeometryArray.ALLOW_COUNT_READ)) throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray0")); return ((IndexedGeometryArrayRetained)this.retained).getIndexCount(); } /** * Sets the valid index count for this IndexedGeometryArray object. * This count specifies the number of indexed vertices actually used * in rendering or other operations such as picking and collision. * This attribute is initialized to <code>indexCount</code>. * * @param validIndexCount the new valid index count. * * @exception CapabilityNotSetException if the appropriate capability is * not set and this object is part of a live or compiled scene graph * * @exception IllegalArgumentException if either of the following is true: * <ul> * <code>validIndexCount < 0</code>, or<br> * <code>initialIndexIndex + validIndexCount > indexCount</code><br> * </ul> * * @exception ArrayIndexOutOfBoundsException if any element in the range * <code>[initialIndexIndex, initialIndexIndex+validIndexCount-1]</code> * in the index array associated with any of the enabled vertex * components (coord, color, normal, texcoord) is out of range. * An element is out of range if it is less than 0 or is greater * than or equal to the number of vertices actually defined for * the particular component's array. * * @exception ArrayIndexOutOfBoundsException if the data mode for this geometry * array object is <code>BY_REFERENCE_INDICES</code> and * <code>coordIndices.length < (initialIndexIndex + validIndexCount)</code>. * * @since Java 3D 1.3 */ public void setValidIndexCount(int validIndexCount) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_COUNT_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("IndexedGeometryArray16")); ((IndexedGeometryArrayRetained)this.retained).setValidIndexCount(validIndexCount); } /** * Gets the valid index count for this IndexedGeometryArray * object. For geometry strip primitives (subclasses of * IndexedGeometryStripArray), the valid index count is defined * to be the sum of the stripIndexCounts array. * * @return the current valid index count * * @exception CapabilityNotSetException if the appropriate capability is * not set and this object is part of a live or compiled scene graph * * @since Java 3D 1.3 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -