javax.media.j3d.GeometryArray Maven / Gradle / Ivy
/* * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Sun designates this * particular file as subject to the "Classpath" exception as provided * by Sun in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. * */ package javax.media.j3d; import javax.vecmath.Color3b; import javax.vecmath.Color3f; import javax.vecmath.Color4b; import javax.vecmath.Color4f; import javax.vecmath.Point2f; import javax.vecmath.Point3d; import javax.vecmath.Point3f; import javax.vecmath.Point4f; import javax.vecmath.TexCoord2f; import javax.vecmath.TexCoord3f; import javax.vecmath.TexCoord4f; import javax.vecmath.Vector3f; /** * The GeometryArray object contains separate arrays of positional * coordinates, colors, normals, texture coordinates, and vertex * attributes that * describe point, line, or polygon geometry. This class is extended * to create the various primitive types (such as lines, * triangle strips, etc.). * Vertex data may be passed to this geometry array in one of two * ways: by copying the data into the array using the existing * methods, or by passing a reference to the data. *
INTERLEAVED. * * @param initialCoordIndex the new initial coordinate index. * * @exception CapabilityNotSetException if the appropriate capability is * not set and this object is part of a live or compiled scene graph **
*
*- * By Copying: * The existing methods for setting positional coordinates, colors, * normals, texture coordinates, and vertex attributes * (such as
*setCoordinate
, *setColors
, etc.) copy the data into this * GeometryArray. This is appropriate for many applications and * offers an application much flexibility in organizing its data. * This is the default mode. *- By Reference: * A new set of methods in Java 3D version 1.2 allows data to be * accessed by reference, directly from the user's arrays. To use * this feature, set the
*BY_REFERENCE
bit in the *vertexFormat
field of the constructor for this * GeometryArray. In this mode, the various set methods for * coordinates, normals, colors, texture coordinates, and vertex attributes * are not used. * Instead, new methods are used to set a reference to user-supplied * coordinate, color, normal, texture coordinate, and vertex attribute * arrays (such as *setCoordRefFloat
,setColorRefFloat
, * etc.). Data in any array that is referenced by a live or compiled * GeometryArray object may only be modified via the *updateData
method (subject to the *ALLOW_REF_DATA_WRITE
capability bit). Applications * must exercise care not to violate this rule. If any referenced * geometry data is modified outside of theupdateData
* method, the results are undefined. ** All colors used in the geometry array object must be in the range [0.0,1.0]. * Values outside this range will cause undefined results. * All normals used in the geometry array object must be unit length * vectors. That is their geometric length must be 1.0. Normals that * are not unit length vectors will cause undefined results. *
* Note that the term coordinate, as used in the method names * and method descriptions, actually refers to a set of x, * y, and z coordinates representing the position of a * single vertex. The term coordinates (plural) is used to * indicate sets of x, y, and z coordinates for * multiple vertices. This is somewhat at odds with the mathematical * definition of a coordinate, but is used as a convenient shorthand. * Similarly, the term texture coordinate is used to indicate a * set of texture coordinates for a single vertex, while the term * texture coordinates (plural) is used to indicate sets of * texture coordinates for multiple vertices. */ public abstract class GeometryArray extends Geometry { /** * Specifies that this GeometryArray allows reading the array of * coordinates. */ public static final int ALLOW_COORDINATE_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_COORDINATE_READ; /** * Specifies that this GeometryArray allows writing the array of * coordinates. */ public static final int ALLOW_COORDINATE_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_COORDINATE_WRITE; /** * Specifies that this GeometryArray allows reading the array of * colors. */ public static final int ALLOW_COLOR_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_COLOR_READ; /** * Specifies that this GeometryArray allows writing the array of * colors. */ public static final int ALLOW_COLOR_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_COLOR_WRITE; /** * Specifies that this GeometryArray allows reading the array of * normals. */ public static final int ALLOW_NORMAL_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_NORMAL_READ; /** * Specifies that this GeometryArray allows writing the array of * normals. */ public static final int ALLOW_NORMAL_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_NORMAL_WRITE; /** * Specifies that this GeometryArray allows reading the array of * texture coordinates. */ public static final int ALLOW_TEXCOORD_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_TEXCOORD_READ; /** * Specifies that this GeometryArray allows writing the array of * texture coordinates. */ public static final int ALLOW_TEXCOORD_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_TEXCOORD_WRITE; /** * Specifies that this GeometryArray allows reading the array of * vertex attributes. * * @since Java 3D 1.4 */ public static final int ALLOW_VERTEX_ATTR_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_READ; /** * Specifies that this GeometryArray allows writing the array of * vertex attributes. * * @since Java 3D 1.4 */ public static final int ALLOW_VERTEX_ATTR_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_VERTEX_ATTR_WRITE; /** * Specifies that this GeometryArray allows reading the count or * initial index information for this object. */ public static final int ALLOW_COUNT_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_COUNT_READ; /** * Specifies that this GeometryArray allows writing the count or * initial index information for this object. * * @since Java 3D 1.2 */ public static final int ALLOW_COUNT_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_COUNT_WRITE; /** * Specifies that this GeometryArray allows reading the vertex format * information for this object. */ public static final int ALLOW_FORMAT_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_FORMAT_READ; /** * Specifies that this GeometryArray allows reading the geometry * data reference information for this object. This is only used in * by-reference geometry mode. * * @since Java 3D 1.2 */ public static final int ALLOW_REF_DATA_READ = CapabilityBits.GEOMETRY_ARRAY_ALLOW_REF_DATA_READ; private static final int J3D_1_2_ALLOW_REF_DATA_READ = CapabilityBits.J3D_1_2_GEOMETRY_ARRAY_ALLOW_REF_DATA_READ; /** * Specifies that this GeometryArray allows writing the geometry * data reference information for this object. It also enables * writing the referenced data itself, via the GeometryUpdater * interface. This is only used in by-reference geometry mode. * * @since Java 3D 1.2 */ public static final int ALLOW_REF_DATA_WRITE = CapabilityBits.GEOMETRY_ARRAY_ALLOW_REF_DATA_WRITE; /** * Specifies that this GeometryArray contains an array of coordinates. * This bit must be set. */ public static final int COORDINATES = 0x01; /** * Specifies that this GeometryArray contains an array of normals. */ public static final int NORMALS = 0x02; /** * Specifies that this GeometryArray contains an array of colors. */ static final int COLOR = 0x04; /** * Specifies that this GeometryArray's colors contain alpha. */ static final int WITH_ALPHA = 0x08; /** * Specifies that this GeometryArray contains an array of colors without alpha. */ public static final int COLOR_3 = COLOR; /** * Specifies that this GeometryArray contains an array of colors with alpha. * This takes precedence over COLOR_3. */ public static final int COLOR_4 = COLOR | WITH_ALPHA; /** * Specifies that this GeometryArray contains one or more arrays of * 2D texture coordinates. */ public static final int TEXTURE_COORDINATE_2 = 0x20; /** * Specifies that this GeometryArray contains one or more arrays of * 3D texture coordinates. * This takes precedence over TEXTURE_COORDINATE_2. */ public static final int TEXTURE_COORDINATE_3 = 0x40; /** * Specifies that this GeometryArray contains one or more arrays of * 4D texture coordinates. * This takes precedence over TEXTURE_COORDINATE_2 and TEXTURE_COORDINATE_3. * * @since Java 3D 1.3 */ public static final int TEXTURE_COORDINATE_4 = 0x400; static final int TEXTURE_COORDINATE = TEXTURE_COORDINATE_2 | TEXTURE_COORDINATE_3 | TEXTURE_COORDINATE_4; /** * Specifies that the position, color, normal, and texture coordinate * data for this GeometryArray are accessed by reference. * * @since Java 3D 1.2 */ public static final int BY_REFERENCE = 0x80; /** * Specifies that the position, color, normal, and texture * coordinate data for this GeometryArray are accessed via a single * interleaved, floating-point array reference. All of the data * values for each vertex are stored in consecutive memory * locations. This flag is only valid in conjunction with the *
BY_REFERENCE
flag. * * @since Java 3D 1.2 */ public static final int INTERLEAVED = 0x100; /** * Specifies that geometry by-reference data for this * GeometryArray, whether interleaved or non-interleaved, is * accessed via J3DBuffer objects that wrap NIO Buffer objects, * rather than float, double, byte, or TupleXX arrays. This flag * is only valid in conjunction with theBY_REFERENCE
* flag. * * @see J3DBuffer * @see #setCoordRefBuffer(J3DBuffer) * @see #setColorRefBuffer(J3DBuffer) * @see #setNormalRefBuffer(J3DBuffer) * @see #setTexCoordRefBuffer(int,J3DBuffer) * @see #setVertexAttrRefBuffer(int,J3DBuffer) * @see #setInterleavedVertexBuffer(J3DBuffer) * * @since Java 3D 1.3 */ public static final int USE_NIO_BUFFER = 0x800; /** * Specifies that only the coordinate indices are used for indexed * geometry arrays. In this mode, the values from the coordinate * index array are used as a single set of index values to access * the vertex data for all five vertex components (coord, color, * normal, texCoord, and vertexAttr). The color, normal, texCoord, * and vertexAttr index arrays are neither allocated nor used. Any * attempt to access the color, normal, texCoord, * or vertexAttr index arrays will result in a NullPointerException. * This flag is only valid for indexed geometry arrays * (subclasses of IndexedGeometryArray). * * @since Java 3D 1.3 */ public static final int USE_COORD_INDEX_ONLY = 0x200; /** * Specifies that this GeometryArray contains one or more arrays of * vertex attributes. These attributes are used in programmable * shading. * * @since Java 3D 1.4 */ public static final int VERTEX_ATTRIBUTES = 0x1000; //NVaidya /** * Specifies that the indices in this GeometryArray * are accessed by reference. This flag is only valid for * indexed geometry arrays (subclasses of IndexedGeometryArray) and only * when used in conjunction with theBY_REFERENCE
and *USE_COORD_INDEX_ONLY
flags. * * @since Java 3D 1.5 */ public static final int BY_REFERENCE_INDICES = 0x2000; // Used to keep track of the last bit (for adding new bits only) private static final int LAST_FORMAT_BIT = 0x2000; // Scratch arrays for converting Point[234]f to TexCoord[234]f private TexCoord2f [] texCoord2fArray = null; private TexCoord3f [] texCoord3fArray = null; private TexCoord4f [] texCoord4fArray = null; private TexCoord2f texCoord2fScratch = null; private TexCoord3f texCoord3fScratch = null; private static final int[] defTexCoordMap = { 0 }; // Array for setting default read capabilities private static final int[] readCapabilities = { ALLOW_COLOR_READ, ALLOW_COORDINATE_READ, ALLOW_COUNT_READ, ALLOW_FORMAT_READ, ALLOW_NORMAL_READ, ALLOW_REF_DATA_READ, ALLOW_TEXCOORD_READ, ALLOW_VERTEX_ATTR_READ }; // non-public, no parameter constructor GeometryArray() { // set default read capabilities setDefaultReadCapabilities(readCapabilities); } //NVaidya /** * Constructs an empty GeometryArray object with the specified * number of vertices and vertex format. Defaults are used * for all other parameters. The default values are as follows: ** texCoordSetCount : 1
* * @param vertexCount the number of vertex elements in this GeometryArray * @param vertexFormat a mask indicating which components are * present in each vertex. This is specified as one or more * individual flags that are bitwise "OR"ed together to describe * the per-vertex data. * The flags include:
* texCoordSetMap : { 0 }
* vertexAttrCount : 0
* vertexAttrSizes : null
* validVertexCount : vertexCount
* initialVertexIndex : 0
* initialCoordIndex : 0
* initialColorIndex : 0
* initialNormalIndex : 0
* initialTexCoordIndex : 0
* initialVertexAttrIndex : 0
* all data array values : 0.0
* all data array references : null
*COORDINATES
, to signal the inclusion of * vertex positions--always present;NORMALS
, to signal * the inclusion of per vertex normals; one ofCOLOR_3
or *COLOR_4
, to signal the inclusion of per vertex * colors (without or with alpha information); one of *TEXTURE_COORDINATE_2
,TEXTURE_COORDINATE_3
* orTEXTURE_COORDINATE_4
, * to signal the * inclusion of per-vertex texture coordinates (2D, 3D or 4D); *BY_REFERENCE
, to indicate that the data is passed * by reference * rather than by copying;INTERLEAVED
, to indicate * that the referenced * data is interleaved in a single array; *USE_NIO_BUFFER
, to indicate that the referenced data * is accessed via a J3DBuffer object that wraps an NIO buffer; *USE_COORD_INDEX_ONLY
, * to indicate that only the coordinate indices are used for indexed * geometry arrays; *BY_REFERENCE_INDICES
, to indicate * that the indices are accessed by reference in indexed * geometry arrays.* * @exception IllegalArgumentException if vertexCount < 0 * * @exception IllegalArgumentException if vertexFormat does not * include
COORDINATES
* * @exception IllegalArgumentException if theUSE_COORD_INDEX_ONLY
* bit or theBY_REFERENCE_INDICES
bit is set for * non-indexed geometry arrays (that is, GeometryArray objects * that are not a subclass of IndexedGeometryArray) * * @exception IllegalArgumentException if theINTERLEAVED
* bit is set without theBY_REFERENCE
bit being set * * @exception IllegalArgumentException if theUSE_NIO_BUFFER
* bit is set without theBY_REFERENCE
bit being set * * @exception IllegalArgumentException if theINTERLEAVED
* bit and theVERTEX_ATTRIBUTES
bit are both set * * @exception IllegalArgumentException if the *BY_REFERENCE_INDICES
* bit is set without theBY_REFERENCE
and *USE_COORD_INDEX_ONLY
bits being set */ public GeometryArray(int vertexCount, int vertexFormat) { this(vertexCount, vertexFormat, ((vertexFormat & TEXTURE_COORDINATE) != 0 ? 1 : 0), ((vertexFormat & TEXTURE_COORDINATE) != 0 ? defTexCoordMap : null)); } //NVaidya /** * Constructs an empty GeometryArray object with the specified * number of vertices, vertex format, number of texture coordinate * sets, and texture coordinate mapping array. Defaults are used * for all other parameters. * * @param vertexCount the number of vertex elements in this * GeometryArray* * @param vertexFormat a mask indicating which components are * present in each vertex. This is specified as one or more * individual flags that are bitwise "OR"ed together to describe * the per-vertex data. * The flags include:
COORDINATES
, to signal the inclusion of * vertex positions--always present;NORMALS
, to signal * the inclusion of per vertex normals; one ofCOLOR_3
or *COLOR_4
, to signal the inclusion of per vertex * colors (without or with alpha information); one of *TEXTURE_COORDINATE_2
orTEXTURE_COORDINATE_3
* orTEXTURE_COORDINATE_4
, * to signal the * inclusion of per-vertex texture coordinates (2D , 3D or 4D); *BY_REFERENCE
, to indicate that the data is passed * by reference * rather than by copying;INTERLEAVED
, to indicate * that the referenced * data is interleaved in a single array; *USE_NIO_BUFFER
, to indicate that the referenced data * is accessed via a J3DBuffer object that wraps an NIO buffer; *USE_COORD_INDEX_ONLY
, * to indicate that only the coordinate indices are used for indexed * geometry arrays; *BY_REFERENCE_INDICES
, to indicate * that the indices are accessed by reference in indexed * geometry arrays.* * @param texCoordSetCount the number of texture coordinate sets * in this GeometryArray object. If
vertexFormat
* does not include one ofTEXTURE_COORDINATE_2
or *TEXTURE_COORDINATE_3
, the *texCoordSetCount
parameter is not used.* @exception IllegalStateException if the data mode for this geometry * array object is not
BY_REFERENCE
or if the data mode * isINTERLEAVED
. ** @exception IllegalArgumentException if either of the following are * true: *
-
*
initialCoordIndex < 0
or*
initialCoordIndex + validVertexCount > vertexCount
*
* @exception ArrayIndexOutOfBoundsException if * the CoordRef array is non-null and: *
-
*
CoordRef.length
< num_words *
* (initialCoordIndex + validVertexCount
)*
setCoordRef
is used.
*
* @since Java 3D 1.2
*/
public void setInitialCoordIndex(int initialCoordIndex) {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray90"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if (initialCoordIndex < 0)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray97"));
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setInitialCoordIndex(initialCoordIndex);
// NOTE: the check for initialCoordIndex + validVertexCount >
// vertexCount needs to be done in the retained method
}
/**
* Gets the initial coordinate index for this GeometryArray object.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
* @return the current initial coordinate index for this
* GeometryArray object.
* @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.2
*/
public int getInitialCoordIndex() {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_READ))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray91"));
return ((GeometryArrayRetained)this.retained).getInitialCoordIndex();
}
/**
* Sets the initial color index for this GeometryArray object.
* This index specifies the first color within the array of
* colors referenced by this geometry
* array that is actually used in rendering or other operations
* such as picking and collision. This attribute is initialized
* to 0.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
*
* @param initialColorIndex the new initial color index.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
or if the data mode
* is INTERLEAVED
.
*
* @exception IllegalArgumentException if either of the following are * true: *
-
*
initialColorIndex < 0
or*
initialColorIndex + validVertexCount > vertexCount
*
* @exception ArrayIndexOutOfBoundsException if * the ColorRef array is non-null and: *
-
*
ColorRef.length
< num_words *
* (initialColorIndex + validVertexCount
)*
setColorRef
is used.
*
* @since Java 3D 1.2
*/
public void setInitialColorIndex(int initialColorIndex) {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray90"));
if (initialColorIndex < 0)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray97"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setInitialColorIndex(initialColorIndex);
// NOTE: the check for initialColorIndex + validVertexCount >
// vertexCount needs to be done in the retained method
}
/**
* Gets the initial color index for this GeometryArray object.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
* @return the current initial color index for this
* GeometryArray object.
* @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.2
*/
public int getInitialColorIndex() {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_READ))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray91"));
return ((GeometryArrayRetained)this.retained).getInitialColorIndex();
}
/**
* Sets the initial normal index for this GeometryArray object.
* This index specifies the first normal within the array of
* normals referenced by this geometry
* array that is actually used in rendering or other operations
* such as picking and collision. This attribute is initialized
* to 0.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
*
* @param initialNormalIndex the new initial normal index.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
or if the data mode
* is INTERLEAVED
.
*
* @exception IllegalArgumentException if either of the following are * true: *
-
*
initialNormalIndex < 0
or*
initialNormalIndex + validVertexCount > vertexCount
*
* @exception ArrayIndexOutOfBoundsException if normals * the NormalRef array is non-null and: *
-
*
NormalRef.length
< num_words *
* (initialNormalIndex + validVertexCount
)*
setNormalRef
is used.
*
* @since Java 3D 1.2
*/
public void setInitialNormalIndex(int initialNormalIndex) {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray90"));
if (initialNormalIndex < 0)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray97"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setInitialNormalIndex(initialNormalIndex);
// NOTE: the check for initialNormalIndex + validVertexCount >
// vertexCount needs to be done in the retained method
}
/**
* Gets the initial normal index for this GeometryArray object.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
* @return the current initial normal index for this
* GeometryArray object.
* @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.2
*/
public int getInitialNormalIndex() {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_READ))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray91"));
return ((GeometryArrayRetained)this.retained).getInitialNormalIndex();
}
/**
* Sets the initial texture coordinate index for the specified
* texture coordinate set for this GeometryArray object. This
* index specifies the first texture coordinate within the array
* of texture coordinates referenced by this geometry array that
* is actually used in rendering or other operations such as
* picking and collision. This attribute is initialized to 0.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
*
* @param texCoordSet texture coordinate set in this geometry array
* @param initialTexCoordIndex the new initial texture coordinate index.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
or if the data mode
* is INTERLEAVED
.
*
* @exception IllegalArgumentException if either of the following are * true: *
-
*
initialTexCoordIndex < 0
or*
initialTexCoordIndex + validVertexCount > vertexCount
*
* @exception ArrayIndexOutOfBoundsException if * the TexCoordRef array is non-null and: *
-
*
TexCoordRef.length
< num_words *
* (initialTexCoordIndex + validVertexCount
)*
setTexCoordRef
is used.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* TEXTURE_COORDINATE
bits are set in the
* vertexFormat
or if texCoordSet is out of range.
*
* @since Java 3D 1.2
*/
public void setInitialTexCoordIndex(int texCoordSet,
int initialTexCoordIndex) {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray90"));
if (initialTexCoordIndex < 0)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray97"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setInitialTexCoordIndex(
texCoordSet, initialTexCoordIndex);
// NOTE: the check for initialTexCoordIndex + validVertexCount >
// vertexCount needs to be done in the retained method
}
/**
* Gets the initial texture coordinate index for the specified
* texture coordinate set for this GeometryArray object.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
*
* @param texCoordSet texture coordinate set in this geometry array
*
* @return the current initial texture coordinate index for the specified
* texture coordinate set
*
* @exception ArrayIndexOutOfBoundsException if none of the
* TEXTURE_COORDINATE
bits are set in the
* vertexFormat
or if texCoordSet is out of range.
*
* @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.2
*/
public int getInitialTexCoordIndex(int texCoordSet) {
if (isLiveOrCompiled())
if(!this.getCapability(ALLOW_COUNT_READ))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray91"));
return ((GeometryArrayRetained)this.retained).getInitialTexCoordIndex(
texCoordSet);
}
/**
* Sets the initial vertex attribute index for the specified
* vertex attribute number for this GeometryArray object. This
* index specifies the first vertex attribute within the array
* of vertex attributes referenced by this geometry array that
* is actually used in rendering or other operations such as
* picking and collision. This attribute is initialized to 0.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
*
* @param vertexAttrNum vertex attribute number in this geometry array
* @param initialVertexAttrIndex the new initial vertex attribute index.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
or if the data mode
* is INTERLEAVED
.
*
* @exception IllegalArgumentException if either of the following are * true: *
-
*
initialVertexAttrIndex < 0
or*
initialVertexAttrIndex + validVertexCount > vertexCount
*
* @exception ArrayIndexOutOfBoundsException if * the VertexAttrRef array is non-null and: *
-
*
VertexAttrRef.length
< num_words *
* (initialVertexAttrIndex + validVertexCount
)*
* @exception ArrayIndexOutOfBoundsException if vertexAttrNum is
* out of range.
*
* @since Java 3D 1.4
*/
public void setInitialVertexAttrIndex(int vertexAttrNum,
int initialVertexAttrIndex) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_COUNT_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray90"));
}
}
if (initialVertexAttrIndex < 0) {
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray97"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
}
if ((format & INTERLEAVED) != 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
}
((GeometryArrayRetained)this.retained).setInitialVertexAttrIndex(
vertexAttrNum, initialVertexAttrIndex);
// NOTE: the check for initialVertexAttrIndex + validVertexCount >
// vertexCount needs to be done in the retained method
}
/**
* Gets the initial vertex attribute index for the specified
* vertex attribute number for this GeometryArray object.
* This attribute is only used when the data mode for this
* geometry array object is BY_REFERENCE
* and is not INTERLEAVED.
*
* @param vertexAttrNum vertex attribute number in this geometry array
*
* @return the current initial vertex attribute index for the specified
* vertex attribute number
*
* @exception ArrayIndexOutOfBoundsException if vertexAttrNum is
* out of range.
*
* @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.4
*/
public int getInitialVertexAttrIndex(int vertexAttrNum) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_COUNT_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray91"));
}
}
return ((GeometryArrayRetained)this.retained).getInitialVertexAttrIndex(
vertexAttrNum);
}
/**
* Sets the coordinate buffer reference to the specified
* buffer object. The buffer contains either a java.nio.FloatBuffer
* or java.nio.DoubleBuffer object containing single or double
* precision floating-point x, y,
* and z values for each vertex (for a total of 3*n
* values, where n is the number of vertices).
* If the coordinate buffer
* reference is null, the entire geometry array object is
* treated as if it were null--any Shape3D or Morph node that uses
* this geometry array will not be drawn.
*
* @param coords a J3DBuffer object to which a reference will be set.
* The buffer contains an NIO buffer of 3*n float or
* double values.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception IllegalArgumentException if the java.nio.Buffer
* contained in the specified J3DBuffer is not a
* java.nio.FloatBuffer or a java.nio.DoubleBuffer object.
*
* @exception ArrayIndexOutOfBoundsException if
* coords.getBuffer().limit() <
* 3 * (initialCoordIndex + validVertexCount)
.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the coordinate index array is greater than or equal to the
* number of vertices defined by the coords object,
* coords.getBuffer().limit() / 3
.
*
* @since Java 3D 1.3
*/
public void setCoordRefBuffer(J3DBuffer coords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setCoordRefBuffer(coords);
}
/**
* Gets the coordinate array buffer reference.
* @return the current coordinate array buffer reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.3
*/
public J3DBuffer getCoordRefBuffer() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getCoordRefBuffer();
}
/**
* Sets the float coordinate array reference to the specified
* array. The array contains floating-point x, y,
* and z values for each vertex (for a total of 3*n
* values, where n is the number of vertices). Only one of
* coordRefFloat
, coordRefDouble
,
* coordRef3f
, or coordRef3d
may be
* non-null (or they may all be null). An attempt to set more
* than one of these attributes to a non-null reference will
* result in an exception being thrown. If all coordinate array
* references are null, the entire geometry array object is
* treated as if it were null--any Shape3D or Morph node that uses
* this geometry array will not be drawn.
*
* @param coords an array of 3*n values to which a
* reference will be set.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
* @exception IllegalArgumentException if the specified array is
* non-null and any other coordinate reference is also non-null.
* @exception ArrayIndexOutOfBoundsException if
* coords.length < 3 * (initialCoordIndex + validVertexCount)
.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the coordinate index array is greater than or equal to the
* number of vertices defined by the coords array,
* coords.length / 3
.
*
* @since Java 3D 1.2
*/
public void setCoordRefFloat(float[] coords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setCoordRefFloat(coords);
}
/**
* Gets the float coordinate array reference.
* @return the current float coordinate array reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.2
*/
public float[] getCoordRefFloat() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getCoordRefFloat();
}
/**
* Sets the double coordinate array reference to the specified
* array. The array contains double-precision
* floating-point x, y,
* and z values for each vertex (for a total of 3*n
* values, where n is the number of vertices). Only one of
* coordRefFloat
, coordRefDouble
,
* coordRef3f
, or coordRef3d
may be
* non-null (or they may all be null). An attempt to set more
* than one of these attributes to a non-null reference will
* result in an exception being thrown. If all coordinate array
* references are null, the entire geometry array object is
* treated as if it were null--any Shape3D or Morph node that uses
* this geometry array will not be drawn.
*
* @param coords an array of 3*n values to which a
* reference will be set.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
* @exception IllegalArgumentException if the specified array is
* non-null and any other coordinate reference is also non-null.
* @exception ArrayIndexOutOfBoundsException if
* coords.length < 3 * (initialCoordIndex + validVertexCount)
.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the coordinate index array is greater than or equal to the
* number of vertices defined by the coords array,
* coords.length / 3
.
*
* @since Java 3D 1.2
*/
public void setCoordRefDouble(double[] coords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setCoordRefDouble(coords);
}
/**
* Gets the double coordinate array reference.
* @return the current double coordinate array reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.2
*/
public double[] getCoordRefDouble() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getCoordRefDouble();
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Point3f arrays
*
* @since Java 3D 1.2
*/
public void setCoordRef3f(Point3f[] coords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setCoordRef3f(coords);
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Point3f arrays
*
* @since Java 3D 1.2
*/
public Point3f[] getCoordRef3f() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getCoordRef3f();
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Point3d arrays
*
* @since Java 3D 1.2
*/
public void setCoordRef3d(Point3d[] coords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setCoordRef3d(coords);
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Point3d arrays
*
* @since Java 3D 1.2
*/
public Point3d[] getCoordRef3d() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getCoordRef3d();
}
/**
* Sets the color buffer reference to the specified
* buffer object. The buffer contains either a java.nio.FloatBuffer
* or java.nio.ByteBuffer object containing floating-point
* or byte red, green,
* blue, and, optionally, alpha values for each
* vertex (for a total of 3*n or 4*n values, where
* n is the number of vertices).
* If the color buffer reference is null and colors are enabled
* (that is, the vertexFormat includes either COLOR_3
or
* COLOR_4
), the entire geometry array object is
* treated as if it were null--any Shape3D or Morph node that uses
* this geometry array will not be drawn.
*
* @param colors a J3DBuffer object to which a reference will be set.
* The buffer contains an NIO buffer of 3*n or 4*n
* float or byte values.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception IllegalArgumentException if the java.nio.Buffer
* contained in the specified J3DBuffer is not a
* java.nio.FloatBuffer or a java.nio.ByteBuffer object.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* COLOR
bits are set in the
* vertexFormat
, or if
* colors.getBuffer().limit() <
num_words *
* (initialColorIndex + validVertexCount)
,
* where num_words is 3 or 4 depending on the vertex color format.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the color index array is greater than or equal to the
* number of vertices defined by the colors object,
* colors.getBuffer().limit() /
num_words.
*
* @since Java 3D 1.3
*/
public void setColorRefBuffer(J3DBuffer colors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setColorRefBuffer(colors);
}
/**
* Gets the color array buffer reference.
* @return the current color array buffer reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.3
*/
public J3DBuffer getColorRefBuffer() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getColorRefBuffer();
}
/**
* Sets the float color array reference to the specified array.
* The array contains floating-point red, green,
* blue, and, optionally, alpha values for each
* vertex (for a total of 3*n or 4*n values, where
* n is the number of vertices). Only one of
* colorRefFloat
, colorRefByte
,
* colorRef3f
, colorRef4f
,
* colorRef3b
, or colorRef4b
may be
* non-null (or they may all be null). An attempt to set more
* than one of these attributes to a non-null reference will
* result in an exception being thrown. If all color array
* references are null and colors are enabled (that is, the
* vertexFormat includes either COLOR_3
or
* COLOR_4
), the entire geometry array object is
* treated as if it were null--any Shape3D or Morph node that uses
* this geometry array will not be drawn.
*
* @param colors an array of 3*n or 4*n values to which a
* reference will be set.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
* @exception IllegalArgumentException if the specified array is
* non-null and any other color reference is also non-null.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* COLOR
bits are set in the
* vertexFormat
, or if
* colors.length <
num_words *
* (initialColorIndex + validVertexCount)
,
* where num_words is 3 or 4 depending on the vertex color format.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the color index array is greater than or equal to the
* number of vertices defined by the colors array,
* colors.length /
num_words.
*
* @since Java 3D 1.2
*/
public void setColorRefFloat(float[] colors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setColorRefFloat(colors);
}
/**
* Gets the float color array reference.
* @return the current float color array reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.2
*/
public float[] getColorRefFloat() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getColorRefFloat();
}
/**
* Sets the byte color array reference to the specified array.
* The array contains red, green,
* blue, and, optionally, alpha values for each
* vertex (for a total of 3*n or 4*n values, where
* n is the number of vertices). Only one of
* colorRefFloat
, colorRefByte
,
* colorRef3f
, colorRef4f
,
* colorRef3b
, or colorRef4b
may be
* non-null (or they may all be null). An attempt to set more
* than one of these attributes to a non-null reference will
* result in an exception being thrown. If all color array
* references are null and colors are enabled (that is, the
* vertexFormat includes either COLOR_3
or
* COLOR_4
), the entire geometry array object is
* treated as if it were null--any Shape3D or Morph node that uses
* this geometry array will not be drawn.
*
* @param colors an array of 3*n or 4*n values to which a
* reference will be set.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
* @exception IllegalArgumentException if the specified array is
* non-null and any other color reference is also non-null.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* COLOR
bits are set in the
* vertexFormat
, or if
* colors.length <
num_words *
* (initialColorIndex + validVertexCount)
,
* where num_words is 3 or 4 depending on the vertex color format.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the color index array is greater than or equal to the
* number of vertices defined by the colors array,
* colors.length /
num_words.
*
* @since Java 3D 1.2
*/
public void setColorRefByte(byte[] colors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setColorRefByte(colors);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* Gets the byte color array reference.
* @return the current byte color array reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.2
*/
public byte[] getColorRefByte() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getColorRefByte();
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color3f arrays
*
* @since Java 3D 1.2
*/
public void setColorRef3f(Color3f[] colors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
if ((format & WITH_ALPHA) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray92"));
((GeometryArrayRetained)this.retained).setColorRef3f(colors);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color3f arrays
*
* @since Java 3D 1.2
*/
public Color3f[] getColorRef3f() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getColorRef3f();
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color4f arrays
*
* @since Java 3D 1.2
*/
public void setColorRef4f(Color4f[] colors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
if ((format & WITH_ALPHA) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray93"));
((GeometryArrayRetained)this.retained).setColorRef4f(colors);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color4f arrays
*
* @since Java 3D 1.2
*/
public Color4f[] getColorRef4f() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getColorRef4f();
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color3b arrays
*
* @since Java 3D 1.2
*/
public void setColorRef3b(Color3b[] colors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
if ((format & WITH_ALPHA) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray92"));
((GeometryArrayRetained)this.retained).setColorRef3b(colors);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color3b arrays
*
* @since Java 3D 1.2
*/
public Color3b[] getColorRef3b() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getColorRef3b();
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color4b arrays
*
* @since Java 3D 1.2
*/
public void setColorRef4b(Color4b[] colors) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
if ((format & WITH_ALPHA) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray93"));
((GeometryArrayRetained)this.retained).setColorRef4b(colors);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Color4b arrays
*
* @since Java 3D 1.2
*/
public Color4b[] getColorRef4b() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getColorRef4b();
}
/**
* Sets the normal buffer reference to the specified
* buffer object. The buffer contains a java.nio.FloatBuffer
* object containing nx, ny,
* and nz values for each vertex (for a total of 3*n
* values, where n is the number of vertices).
* If the normal buffer reference is null and normals are enabled
* (that is, the vertexFormat includes NORMAL
), the
* entire geometry array object is treated as if it were null--any
* Shape3D or Morph node that uses this geometry array will not be
* drawn.
*
* @param normals a J3DBuffer object to which a reference will be set.
* The buffer contains an NIO buffer of 3*n float values.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception IllegalArgumentException if the java.nio.Buffer
* contained in the specified J3DBuffer is not a
* java.nio.FloatBuffer object.
*
* @exception ArrayIndexOutOfBoundsException if
* NORMALS
bit is not set in the
* vertexFormat
, or if
* normals.getBuffer().limit() <
* 3 * (initialNormalIndex + validVertexCount)
.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the normal index array is greater than or equal to the
* number of vertices defined by the normals object,
* normals.getBuffer().limit() / 3
.
*
* @since Java 3D 1.3
*/
public void setNormalRefBuffer(J3DBuffer normals) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setNormalRefBuffer(normals);
}
/**
* Gets the normal array buffer reference.
* @return the current normal array buffer reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.3
*/
public J3DBuffer getNormalRefBuffer() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getNormalRefBuffer();
}
/**
* Sets the float normal array reference to the specified
* array. The array contains floating-point nx, ny,
* and nz values for each vertex (for a total of 3*n
* values, where n is the number of vertices). Only one of
* normalRefFloat
or normalRef3f
may be
* non-null (or they may all be null). An attempt to set more
* than one of these attributes to a non-null reference will
* result in an exception being thrown. If all normal array
* references are null and normals are enabled (that is, the
* vertexFormat includes
* NORMAL
), the entire geometry array object is
* treated as if it were null--any Shape3D or Morph node that uses
* this geometry array will not be drawn.
*
* @param normals an array of 3*n values to which a
* reference will be set.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
* @exception IllegalArgumentException if the specified array is
* non-null and any other normal reference is also non-null.
* @exception ArrayIndexOutOfBoundsException if
* NORMALS
bit is not set in the
* vertexFormat
, or if
* normals.length < 3 * (initialNormalIndex + validVertexCount)
.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the normal index array is greater than or equal to the
* number of vertices defined by the normals array,
* normals.length / 3
.
*
* @since Java 3D 1.2
*/
public void setNormalRefFloat(float[] normals) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setNormalRefFloat(normals);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* Gets the float normal array reference.
* @return the current float normal array reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @since Java 3D 1.2
*/
public float[] getNormalRefFloat() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getNormalRefFloat();
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Vector3f arrays
*
* @since Java 3D 1.2
*/
public void setNormalRef3f(Vector3f[] normals) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setNormalRef3f(normals);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for Vector3f arrays
*
* @since Java 3D 1.2
*/
public Vector3f[] getNormalRef3f() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getNormalRef3f();
}
/**
* Sets the texture coordinate buffer reference for the specified
* texture coordinate set to the
* specified buffer object. The buffer contains a java.nio.FloatBuffer
* object containing s,
* t, and, optionally, r and q values for each
* vertex (for
* a total of 2*n , 3*n or 4*n values,
* where n is
* the number of vertices).
* If the texCoord buffer reference is null and texture
* coordinates are enabled (that is, the vertexFormat includes
* TEXTURE_COORDINATE_2
,
* TEXTURE_COORDINATE_3
, or
* TEXTURE_COORDINATE_4
), the entire geometry
* array object is treated as if it were null--any Shape3D or
* Morph node that uses this geometry array will not be drawn.
*
* @param texCoordSet texture coordinate set in this geometry array
* @param texCoords a J3DBuffer object to which a reference will be set.
* The buffer contains an NIO buffer of 2*n, 3*n or
* 4*n float values.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception IllegalArgumentException if the java.nio.Buffer
* contained in the specified J3DBuffer is not a
* java.nio.FloatBuffer object.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* TEXTURE_COORDINATE
bits are set in the
* vertexFormat
, or if texCoordSet is out of range,
* or if
* texCoords.getBuffer().limit() <
num_words
* * (initialTexCoordIndex + validVertexCount)
,
* where num_words is 2, 3, or 4 depending on the vertex
* texture coordinate format.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the texture coordinate index array is greater than or equal to the
* number of vertices defined by the texCoords object,
* texCoords.getBuffer().limit() /
num_words.
*
* @since Java 3D 1.3
*/
public void setTexCoordRefBuffer(int texCoordSet, J3DBuffer texCoords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setTexCoordRefBuffer(
texCoordSet, texCoords);
}
/**
* Gets the texture coordinate array buffer reference for the specified
* texture coordinate set.
*
* @param texCoordSet texture coordinate set in this geometry array
*
* @return the current texture coordinate array buffer reference
* for the specified texture coordinate set
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* TEXTURE_COORDINATE
bits are set in the
* vertexFormat
or texCoordSet is out of range.
*
* @since Java 3D 1.3
*/
public J3DBuffer getTexCoordRefBuffer(int texCoordSet) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getTexCoordRefBuffer(texCoordSet);
}
/**
* Sets the float texture coordinate array reference for the specified
* texture coordinate set to the
* specified array. The array contains floating-point s,
* t, and, optionally, r and q values for each
* vertex (for
* a total of 2*n , 3*n or 4*n values,
* where n is
* the number of vertices). Only one of
* texCoordRefFloat
, texCoordRef2f
, or
* texCoordRef3f
may be non-null (or they may all be
* null). An attempt to set more than one of these attributes to
* a non-null reference will result in an exception being thrown.
* If all texCoord array references are null and texture
* coordinates are enabled (that is, the vertexFormat includes
* TEXTURE_COORDINATE_2
,
* TEXTURE_COORDINATE_3
, or
* TEXTURE_COORDINATE_4
), the entire geometry
* array object is treated as if it were null--any Shape3D or
* Morph node that uses this geometry array will not be drawn.
*
* @param texCoordSet texture coordinate set in this geometry array
* @param texCoords an array of 2*n, 3*n or
* 4*n values to
* which a reference will be set.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
* @exception IllegalArgumentException if the specified array is
* non-null and any other texCoord reference is also non-null.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* TEXTURE_COORDINATE
bits are set in the
* vertexFormat
, or if texCoordSet is out of range,
* or if
* texCoords.length <
num_words *
* (initialTexCoordIndex + validVertexCount)
,
* where num_words is 2, 3, or 4 depending on the vertex
* texture coordinate format.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the texture coordinate index array is greater than or equal to the
* number of vertices defined by the texCoords array,
* texCoords.length /
num_words.
*
* @since Java 3D 1.2
*/
public void setTexCoordRefFloat(int texCoordSet, float[] texCoords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
((GeometryArrayRetained)this.retained).setTexCoordRefFloat(
texCoordSet, texCoords);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* Gets the float texture coordinate array reference for the specified
* texture coordinate set.
*
* @param texCoordSet texture coordinate set in this geometry array
*
* @return the current float texture coordinate array reference
* for the specified texture coordinate set
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception ArrayIndexOutOfBoundsException if none of the
* TEXTURE_COORDINATE
bits are set in the
* vertexFormat
or texCoordSet is out of range.
*
* @since Java 3D 1.2
*/
public float[] getTexCoordRefFloat(int texCoordSet) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getTexCoordRefFloat(
texCoordSet);
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for TexCoord2f arrays
*
* @since Java 3D 1.2
*/
public void setTexCoordRef2f(int texCoordSet, TexCoord2f[] texCoords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
if ((format & (TEXTURE_COORDINATE_3 | TEXTURE_COORDINATE_4)) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray94"));
((GeometryArrayRetained)this.retained).setTexCoordRef2f(
texCoordSet, texCoords);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for TexCoord2f arrays
*
* @since Java 3D 1.2
*/
public TexCoord2f[] getTexCoordRef2f(int texCoordSet) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getTexCoordRef2f(
texCoordSet);
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for TexCoord3f arrays
*
* @since Java 3D 1.2
*/
public void setTexCoordRef3f(int texCoordSet, TexCoord3f[] texCoords) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
if ((format & (TEXTURE_COORDINATE_2 | TEXTURE_COORDINATE_4)) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray95"));
((GeometryArrayRetained)this.retained).setTexCoordRef3f(
texCoordSet, texCoords);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* @deprecated As of Java 3D version 1.3, use geometry by-copy
* for TexCoord3f arrays
*
* @since Java 3D 1.2
*/
public TexCoord3f[] getTexCoordRef3f(int texCoordSet) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
if ((format & INTERLEAVED) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
return ((GeometryArrayRetained)this.retained).getTexCoordRef3f(
texCoordSet);
}
/**
* Sets the vertex attribute buffer reference for the specified
* vertex attribute number to the specified buffer object. The
* buffer contains a java.nio.FloatBuffer object containing 1, 2,
* 3, or 4 values for each vertex (for a total of 1*n,
* 2*n, 3*n, or 4*n values, where n is
* the number of vertices).
* If the vertexAttr buffer reference is null and vertex
* attributes are enabled (that is, the vertexFormat includes
* VERTEX_ATTRIBUTES
), the entire geometry array
* object is treated as if it were null--any Shape3D node that
* uses this geometry array will not be drawn.
*
* @param vertexAttrNum vertex attribute number in this geometry array
*
* @param vertexAttrs a J3DBuffer object to which a reference will
* be set. The buffer contains an NIO buffer of 1*n,
* 2*n, 3*n, or 4*n float values.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception IllegalArgumentException if the java.nio.Buffer
* contained in the specified J3DBuffer is not a
* java.nio.FloatBuffer object.
*
* @exception ArrayIndexOutOfBoundsException if vertexAttrNum is out of
* range, or if
* vertexAttrs.getBuffer().limit() <
num_words
* * (initialVertexAttrIndex + validVertexCount)
,
* where num_words is the size of the specified
* vertexAttrNum (1, 2, 3, or 4).
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the vertex attribute index array is greater than or equal to the
* number of vertices defined by the vertexAttrs object,
* vertexAttrs.getBuffer().limit() /
num_words.
*
* @since Java 3D 1.4
*/
public void setVertexAttrRefBuffer(int vertexAttrNum, J3DBuffer vertexAttrs) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_REF_DATA_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
}
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
}
if ((format & INTERLEAVED) != 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
}
((GeometryArrayRetained)this.retained).setVertexAttrRefBuffer(
vertexAttrNum, vertexAttrs);
}
/**
* Gets the vertex attribute array buffer reference for the specified
* vertex attribute number.
*
* @param vertexAttrNum vertex attribute number in this geometry array
*
* @return the current vertex attribute array buffer reference
* for the specified vertex attribute number
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is not USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception ArrayIndexOutOfBoundsException if vertexAttrNum is out
* of range.
*
* @since Java 3D 1.4
*/
public J3DBuffer getVertexAttrRefBuffer(int vertexAttrNum) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & USE_NIO_BUFFER) == 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
}
if ((format & INTERLEAVED) != 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
}
return ((GeometryArrayRetained)this.retained).getVertexAttrRefBuffer(vertexAttrNum);
}
/*
* XXXX: add the following to the javadoc if we ever add double-precision
* methods for vertex attribtues.
*
*-----------------------------------------------------------------
* Only one of vertexAttrRefFloat
, or
* vertexAttrRefDouble
may be non-null (or they may
* all be null). An attempt to set more than one of these
* attributes to a non-null reference will result in an exception
* being thrown.
*
* If all vertexAttr array references are null and vertex
* ...
* @exception IllegalArgumentException if the specified array is
* non-null and any other vertexAttr reference is also non-null.
* ...
*-----------------------------------------------------------------
*/
/**
* Sets the float vertex attribute array reference for the
* specified vertex attribute number to the specified array. The
* array contains 1, 2, 3, or 4 floating-point values for each
* vertex (for a total of 1*n, 2*n, 3*n, or
* 4*n values, where n is the number of vertices).
*
* If the vertexAttr array reference is null and vertex
* attributes are enabled (that is, the vertexFormat includes
* VERTEX_ATTRIBUTES
), the entire geometry array
* object is treated as if it were null--any Shape3D node that
* uses this geometry array will not be drawn.
*
* @param vertexAttrNum vertex attribute number in this geometry array
*
* @param vertexAttrs an array of 1*n, 2*n,
* 3*n, or 4*n values to which a reference will be
* set.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception ArrayIndexOutOfBoundsException if vertexAttrNum is
* out of range, or if
* vertexAttrs.length <
num_words *
* (initialVertexAttrIndex + validVertexCount)
,
* where num_words is the size of the specified
* vertexAttrNum (1, 2, 3, or 4).
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the vertex attribute index array is greater than or equal to the
* number of vertices defined by the vertexAttrs array,
* vertexAttrs.length /
num_words.
*
* @since Java 3D 1.4
*/
public void setVertexAttrRefFloat(int vertexAttrNum, float[] vertexAttrs) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_REF_DATA_WRITE)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
}
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
}
if ((format & USE_NIO_BUFFER) != 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
}
if ((format & INTERLEAVED) != 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
}
((GeometryArrayRetained)this.retained).setVertexAttrRefFloat(
vertexAttrNum, vertexAttrs);
// NOTE: the checks for multiple non-null references, and the
// array length check need to be done in the retained method
}
/**
* Gets the float vertex attribute array reference for the specified
* vertex attribute number.
*
* @param vertexAttrNum vertex attribute number in this geometry array
*
* @return the current float vertex attribute array reference
* for the specified vertex attribute number
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not BY_REFERENCE
,
* is USE_NIO_BUFFER
, or is INTERLEAVED
.
*
* @exception ArrayIndexOutOfBoundsException if vertexAttrNum is
* out of range.
*
* @since Java 3D 1.4
*/
public float[] getVertexAttrRefFloat(int vertexAttrNum) {
if (isLiveOrCompiled()) {
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & BY_REFERENCE) == 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray83"));
}
if ((format & USE_NIO_BUFFER) != 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
}
if ((format & INTERLEAVED) != 0) {
throw new IllegalStateException(J3dI18N.getString("GeometryArray84"));
}
return ((GeometryArrayRetained)this.retained).getVertexAttrRefFloat(
vertexAttrNum);
}
/**
* Sets the interleaved vertex array reference to the specified
* array. The vertex components must be stored in a predetermined
* order in the array. The order is: texture coordinates, colors,
* normals, and positional coordinates.
* Vertex attributes are not supported in interleaved mode.
* In the case of texture
* coordinates, the values for each texture coordinate set
* are stored in order from 0 through texCoordSetCount-1. Only those
* components that are enabled appear in the vertex. The number
* of words per vertex depends on which vertex components are
* enabled. Texture coordinates, if enabled, use 2 words per
* texture coordinate set per vertex for
* TEXTURE_COORDINATE_2
, 3 words per texture
* coordinate set per vertex for
* TEXTURE_COORDINATE_3
or 4 words per texture
* coordinate set per vertex for
* TEXTURE_COORDINATE_4
. Colors, if enabled, use 3
* words per vertex for COLOR_3
or 4 words per vertex
* for COLOR_4
. Normals, if enabled, use 3 words per
* vertex. Positional coordinates, which are always enabled, use
* 3 words per vertex. For example, the format of interleaved
* data for a GeometryArray object whose vertexFormat includes
* COORDINATES
, COLOR_3
, and
* NORMALS
would be: red, green,
* blue, Nx, Ny, Nz, x,
* y, z. All components of a vertex are stored in
* adjacent memory locations. The first component of vertex 0 is
* stored beginning at index 0 in the array. The first component
* of vertex 1 is stored beginning at index
* words_per_vertex in the array. The total number of
* words needed to store n vertices is
* words_per_vertex*n.
*
* @param vertexData an array of vertex values to which a
* reference will be set.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not INTERLEAVED
* or is USE_NIO_BUFFER
.
*
* @exception ArrayIndexOutOfBoundsException if
* vertexData.length
< words_per_vertex *
* (initialVertexIndex + validVertexCount
),
* where words_per_vertex depends on which formats are enabled.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the index array associated with any of the enabled vertex
* components (coord, color, normal, texcoord) is greater than or
* equal to the number of vertices defined by the vertexData
* array,
* vertexData.length /
words_per_vertex.
*
* @since Java 3D 1.2
*/
public void setInterleavedVertices(float[] vertexData) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & INTERLEAVED) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray85"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
((GeometryArrayRetained)this.retained).setInterleavedVertices(vertexData);
// NOTE: the array length check needs to be done in the retained method
}
/**
* Gets the interleaved vertices array reference.
* @return the current interleaved vertices array reference.
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
* @exception IllegalStateException if the data mode for this geometry
* array object is not INTERLEAVED
* or is USE_NIO_BUFFER
.
*
* @since Java 3D 1.2
*/
public float[] getInterleavedVertices() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & INTERLEAVED) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray85"));
if ((format & USE_NIO_BUFFER) != 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray119"));
return ((GeometryArrayRetained)this.retained).getInterleavedVertices();
}
/**
* Sets the interleaved vertex buffer reference to the specified
* buffer object. The buffer must contain a java.nio.FloatBuffer object.
* The vertex components must be stored in a predetermined
* order in the buffer. The order is: texture coordinates, colors,
* normals, and positional coordinates.
* Vertex attributes are not supported in interleaved mode.
* In the case of texture
* coordinates, the values for each texture coordinate set
* are stored in order from 0 through texCoordSetCount-1. Only those
* components that are enabled appear in the vertex. The number
* of words per vertex depends on which vertex components are
* enabled. Texture coordinates, if enabled, use 2 words per
* texture coordinate set per vertex for
* TEXTURE_COORDINATE_2
, 3 words per texture
* coordinate set per vertex for
* TEXTURE_COORDINATE_3
or 4 words per texture
* coordinate set per vertex for
* TEXTURE_COORDINATE_4
. Colors, if enabled, use 3
* words per vertex for COLOR_3
or 4 words per vertex
* for COLOR_4
. Normals, if enabled, use 3 words per
* vertex. Positional coordinates, which are always enabled, use
* 3 words per vertex. For example, the format of interleaved
* data for a GeometryArray object whose vertexFormat includes
* COORDINATES
, COLOR_3
, and
* NORMALS
would be: red, green,
* blue, Nx, Ny, Nz, x,
* y, z. All components of a vertex are stored in
* adjacent memory locations. The first component of vertex 0 is
* stored beginning at index 0 in the buffer. The first component
* of vertex 1 is stored beginning at index
* words_per_vertex in the buffer. The total number of
* words needed to store n vertices is
* words_per_vertex*n.
*
* @param vertexData a J3DBuffer object to which a reference will be set.
* The buffer contains an NIO float buffer of
* words_per_vertex*n values.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not INTERLEAVED
* or is not USE_NIO_BUFFER
.
*
* @exception IllegalArgumentException if the java.nio.Buffer
* contained in the specified J3DBuffer is not a
* java.nio.FloatBuffer object.
*
* @exception ArrayIndexOutOfBoundsException if
* vertexData.getBuffer().limit()
< words_per_vertex *
* (initialVertexIndex + validVertexCount
),
* where words_per_vertex depends on which formats are enabled.
*
* @exception ArrayIndexOutOfBoundsException if this GeometryArray
* object is a subclass of IndexedGeometryArray, and any element
* in the range
* [initialIndexIndex, initialIndexIndex+validIndexCount-1]
* in the index array associated with any of the enabled vertex
* components (coord, color, normal, texcoord) is greater than or
* equal to the number of vertices defined by the vertexData
* object,
* vertexData.getBuffer().limit() /
words_per_vertex.
*
* @since Java 3D 1.3
*/
public void setInterleavedVertexBuffer(J3DBuffer vertexData) {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_WRITE))
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray86"));
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & INTERLEAVED) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray85"));
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
((GeometryArrayRetained)this.retained).setInterleavedVertexBuffer(vertexData);
}
/**
* Gets the interleaved vertex array buffer reference.
* @return the current interleaved vertex array buffer reference.
*
* @exception CapabilityNotSetException if the appropriate capability is
* not set and this object is part of a live or compiled scene graph
*
* @exception IllegalStateException if the data mode for this geometry
* array object is not INTERLEAVED
* or is not USE_NIO_BUFFER
.
*
* @since Java 3D 1.3
*/
public J3DBuffer getInterleavedVertexBuffer() {
if (isLiveOrCompiled())
if (!this.getCapability(ALLOW_REF_DATA_READ) &&
!this.getCapability(J3D_1_2_ALLOW_REF_DATA_READ)) {
throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray87"));
}
int format = ((GeometryArrayRetained)this.retained).vertexFormat;
if ((format & INTERLEAVED) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray85"));
if ((format & USE_NIO_BUFFER) == 0)
throw new IllegalStateException(J3dI18N.getString("GeometryArray118"));
return ((GeometryArrayRetained)this.retained).getInterleavedVertexBuffer();
}
}