📄 geometryarray.java
字号:
* @return the number of vertex attributes in this GeometryArray * object * * @since Java 3D 1.4 */ public int getVertexAttrCount() { return ((GeometryArrayRetained)this.retained).getVertexAttrCount(); } /** * Retrieves the vertex attribute sizes array from this * GeometryArray object. * * @param vertexAttrSizes an array that will receive a copy of * the vertex attribute sizes array. The array must hold at least * <code>vertexAttrCount</code> elements. * * @since Java 3D 1.4 */ public void getVertexAttrSizes(int[] vertexAttrSizes) { ((GeometryArrayRetained)this.retained).getVertexAttrSizes(vertexAttrSizes); } /** * Updates geometry array data that is accessed by reference. * This method calls the updateData method of the specified * GeometryUpdater object to synchronize updates to vertex * data that is referenced by this GeometryArray object. * Applications that wish to modify such data must perform all * updates via this method. * <p> * This method may also be used to atomically set multiple * references (for example, to coordinate and color arrays) * or to atomically * change multiple data values through the geometry data copying * methods. * * @param updater object whose updateData callback method will be * called to update the data referenced by this GeometryArray. * @exception CapabilityNotSetException if the appropriate capability * is not set, the vertex data mode is <code>BY_REFERENCE</code>, and this * object is part of a live or compiled scene graph * * @since Java 3D 1.2 */ public void updateData(GeometryUpdater updater) { int format = ((GeometryArrayRetained)this.retained).vertexFormat; if ((format & BY_REFERENCE) != 0 && isLiveOrCompiled() && !this.getCapability(ALLOW_REF_DATA_WRITE)) { throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray81")); } ((GeometryArrayRetained)this.retained).updateData(updater); } /** * Sets the valid vertex count for this GeometryArray object. * This count specifies the number of vertices actually used in * rendering or other operations such as picking and collision. * This attribute is initialized to <code>vertexCount</code>. * * @param validVertexCount the new valid vertex count. * @exception CapabilityNotSetException if the appropriate capability is * not set and this object is part of a live or compiled scene graph * <p> * @exception IllegalArgumentException if any of the following are * true: * <ul> * <code>validVertexCount < 0</code>,<br> * <code>initialVertexIndex + validVertexCount > vertexCount</code>,<br> * <code>initialCoordIndex + validVertexCount > vertexCount</code>,<br> * <code>initialColorIndex + validVertexCount > vertexCount</code>,<br> * <code>initialNormalIndex + validVertexCount > vertexCount</code>,<br> * <code>initialTexCoordIndex + validVertexCount > vertexCount</code>,<br> * <code>initialVertexAttrIndex + validVertexCount > vertexCount</code> * </ul> * <p> * @exception ArrayIndexOutOfBoundsException if the geometry data format * is <code>BY_REFERENCE</code> and any the following * are true for non-null array references: * <ul> * <code>CoordRef.length</code> < <i>num_words</i> * * (<code>initialCoordIndex + validVertexCount</code>),<br> * <code>ColorRef.length</code> < <i>num_words</i> * * (<code>initialColorIndex + validVertexCount</code>),<br> * <code>NormalRef.length</code> < <i>num_words</i> * * (<code>initialNormalIndex + validVertexCount</code>),<br> * <code>TexCoordRef.length</code> < <i>num_words</i> * * (<code>initialTexCoordIndex + validVertexCount</code>),<br> * <code>VertexAttrRef.length</code> < <i>num_words</i> * * (<code>initialVertexAttrIndex + validVertexCount</code>),<br> * <code>InterleavedVertices.length</code> < <i>words_per_vertex</i> * * (<code>initialVertexIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which variant of * <code>set</code><i>Array</i><code>Ref</code> is used, and * <i>words_per_vertex</i> depends on which vertex formats are enabled * for interleaved arrays. * * @since Java 3D 1.2 */ public void setValidVertexCount(int validVertexCount) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_COUNT_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray88")); if (validVertexCount < 0) throw new IllegalArgumentException(J3dI18N.getString("GeometryArray96")); ((GeometryArrayRetained)this.retained).setValidVertexCount(validVertexCount); // NOTE: the checks for initial*Index + validVertexCount > // vertexCount need to be done in the retained method } /** * Gets the valid vertex count for this GeometryArray object. * For geometry strip primitives (subclasses of GeometryStripArray), * the valid vertex count is defined to be the sum of the * stripVertexCounts array. * @return the current valid vertex count * @exception CapabilityNotSetException if the appropriate capability is * not set and this object is part of a live or compiled scene graph * * @since Java 3D 1.2 */ public int getValidVertexCount() { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_COUNT_READ)) throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray89")); return ((GeometryArrayRetained)this.retained).getValidVertexCount(); } /** * Copies all node information from <code>originalNodeComponent</code> * into the current node. This method is called from the * <code>duplicateNode</code> method. This routine does * the actual duplication of all "local data" (any data defined in * this object). * * @param originalNodeComponent the original node to duplicate. * @param forceDuplicate when set to <code>true</code>, causes the * <code>duplicateOnCloneTree</code> flag to be ignored. When * <code>false</code>, the value of each node's * <code>duplicateOnCloneTree</code> variable determines whether * NodeComponent data is duplicated or copied. * * @see Node#cloneTree * @see NodeComponent#setDuplicateOnCloneTree */ void duplicateAttributes(NodeComponent originalNodeComponent, boolean forceDuplicate) { super.duplicateAttributes(originalNodeComponent, forceDuplicate); // vertexFormat and vertexCount are copied in subclass when constructor // public GeometryArray(int vertexCount, int vertexFormat) is used // in cloneNodeComponent() GeometryArrayRetained src = (GeometryArrayRetained) originalNodeComponent.retained; GeometryArrayRetained dst = (GeometryArrayRetained) retained; int format = src.getVertexFormat(); if ((format & BY_REFERENCE) == 0) { System.arraycopy(src.vertexData, 0, dst.vertexData, 0, src.vertexData.length); dst.setInitialVertexIndex(src.getInitialVertexIndex()); } else { dst.setInitialCoordIndex(src.getInitialCoordIndex()); dst.setInitialColorIndex(src.getInitialColorIndex()); dst.setInitialNormalIndex(src.getInitialNormalIndex()); int setCount = src.getTexCoordSetCount(); int vAttrCount = src.getVertexAttrCount(); for (int i=0; i < setCount; i++) { dst.setInitialTexCoordIndex(i, src.getInitialTexCoordIndex(i)); } if ((format & INTERLEAVED) == 0) { if ((format & USE_NIO_BUFFER) == 0) { // Java arrays dst.setCoordRefFloat(src.getCoordRefFloat()); dst.setCoordRefDouble(src.getCoordRefDouble()); dst.setCoordRef3f(src.getCoordRef3f()); dst.setCoordRef3d(src.getCoordRef3d()); dst.setColorRefFloat(src.getColorRefFloat()); dst.setColorRefByte(src.getColorRefByte()); if ((format & WITH_ALPHA) == 0) { dst.setColorRef3f(src.getColorRef3f()); dst.setColorRef3b(src.getColorRef3b()); } else { dst.setColorRef4f(src.getColorRef4f()); dst.setColorRef4b(src.getColorRef4b()); } dst.setNormalRefFloat(src.getNormalRefFloat()); dst.setNormalRef3f(src.getNormalRef3f()); switch (src.getVertexAttrType()) { case GeometryArrayRetained.AF: for (int i=0; i < vAttrCount; i++) { dst.setVertexAttrRefFloat(i, src.getVertexAttrRefFloat(i)); } break; } switch (src.getTexCoordType()) { case GeometryArrayRetained.TF: for (int i=0; i < setCount; i++) { dst.setTexCoordRefFloat(i, src.getTexCoordRefFloat(i)); } break; case GeometryArrayRetained.T2F: for (int i=0; i < setCount; i++) { dst.setTexCoordRef2f(i, src.getTexCoordRef2f(i)); } break; case GeometryArrayRetained.T3F: for (int i=0; i < setCount; i++) { dst.setTexCoordRef3f(i, src.getTexCoordRef3f(i)); } break; } } else { // NIO buffer dst.setCoordRefBuffer(src.getCoordRefBuffer()); dst.setColorRefBuffer(src.getColorRefBuffer()); dst.setNormalRefBuffer(src.getNormalRefBuffer()); switch (src.getVertexAttrType()) { case GeometryArrayRetained.AF: for (int i=0; i < vAttrCount; i++) { dst.setVertexAttrRefBuffer(i, src.getVertexAttrRefBuffer(i)); } break; } switch (src.getTexCoordType()) { case GeometryArrayRetained.TF: for (int i=0; i < setCount; i++) { dst.setTexCoordRefBuffer(i, src.getTexCoordRefBuffer(i)); } break; } } } else { dst.setInterleavedVertices(src.getInterleavedVertices()); } } } //------------------------------------------------------------------ // By-copying methods //------------------------------------------------------------------ /** * Sets the initial vertex index for this GeometryArray object. * This index specifies the first vertex within 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 not <code>BY_REFERENCE</code> * or when the data mode is <code>INTERLEAVED</code>. * * @param initialVertexIndex the new initial vertex index. * @exception CapabilityNotSetException if the appropriate capability is * not set and this object is part of a live or compiled scene graph * @exception IllegalArgumentException if either of the following are * true: * <ul> * <code>initialVertexIndex < 0</code> or<br> * <code>initialVertexIndex + validVertexCount > vertexCount</code><br> * </ul> * * @exception ArrayIndexOutOfBoundsException if the geometry data format * is <code>INTERLEAVED</code>, the InterleavedVertices array is * non-null, and: * <ul> * <code>InterleavedVertices.length</code> < <i>num_words</i> * * (<code>initialVertexIndex + validVertexCount</code>)<br> * </ul> * where <i>num_words</i> depends on which vertex formats are enabled. * * @exception IllegalStateException if the data mode for this geometry * array object is <code>BY_REFERENCE</code> and is <i>not</i> * <code>INTERLEAVED</code>. * * @since Java 3D 1.2 */ public void setInitialVertexIndex(int initialVertexIndex) { if (isLiveOrCompiled()) if(!this.getCapability(ALLOW_COUNT_WRITE)) throw new CapabilityNotSetException(J3dI18N.getString("GeometryArray90")); if (initialVertexIndex < 0) throw new IllegalArgumentException(J3dI18N.getString("GeometryArray97")); int format = ((GeometryArrayRetained)this.retained).vertexFormat; if ((format & BY_REFERENCE) != 0 && (format & INTERLEAVED) == 0) throw new IllegalStateException(J3dI18N.getString("GeometryArray105")); ((GeometryArrayRetained)this.retained).setInitialVertexIndex(initialVertexIndex); // NOTE: the check for initialVertexIndex + validVertexCount > // vertexCount is done in the retained method } /** * Gets the initial vertex index for this GeometryArray object. * This attribute is only used when the data mode for this * geometry array object is <i>not</i> <code>BY_REFERENCE</code>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -