/** * Returns the value of the specified component * * @param globalComponentIndex The global component index * @return The value * @throws IndexOutOfBoundsException If the given index causes the * underlying buffer to be accessed out of bounds */ public float get(int globalComponentIndex) { int elementIndex = globalComponentIndex / getNumComponentsPerElement(); int componentIndex = globalComponentIndex % getNumComponentsPerElement(); return get(elementIndex, componentIndex); }
/** * Returns an array containing the maximum component values of all elements * of this accessor data. This will be an array whose length is the * {@link #getNumComponentsPerElement() number of components per element}. * * @return The minimum values */ public float[] computeMax() { float result[] = new float[getNumComponentsPerElement()]; Arrays.fill(result, -Float.MAX_VALUE); for (int e = 0; e < getNumElements(); e++) { for (int c = 0; c < getNumComponentsPerElement(); c++) { result[c] = Math.max(result[c], get(e, c)); } } return result; }
@Override public ByteBuffer createByteBuffer() { int totalNumComponents = getTotalNumComponents(); int totalBytes = totalNumComponents * getNumBytesPerComponent(); ByteBuffer result = ByteBuffer.allocateDirect(totalBytes) .order(ByteOrder.nativeOrder()); for (int i=0; i<totalNumComponents; i++) { float component = get(i); result.putFloat(component); } result.position(0); return result; }
@Override public float[] getInverseBindMatrix(int index, float[] result) { float localResult[] = Utils.validate(result, 16); AccessorFloatData inverseBindMatricesData = AccessorDatas.createFloat(inverseBindMatrices); for (int j = 0; j < 16; j++) { localResult[j] = inverseBindMatricesData.get(index, j); } return localResult; }
/** * Returns an array containing the minimum component values of all elements * of this accessor data. This will be an array whose length is the * {@link #getNumComponentsPerElement() number of components per element}. * * @return The minimum values */ public float[] computeMin() { float result[] = new float[getNumComponentsPerElement()]; Arrays.fill(result, Float.MAX_VALUE); for (int e = 0; e < getNumElements(); e++) { for (int c = 0; c < getNumComponentsPerElement(); c++) { result[c] = Math.min(result[c], get(e, c)); } } return result; }
point[c] = accessorFloatData.get(e, c);
/** * Set the values of the given target {@link AccessorData} to the same * values as in the given source {@link AccessorData}. If either of * them has fewer elements (or fewer components per element) than the * other, then the minimum of both will be used, respectively. * * @param target The target {@link AccessorData} * @param source The source {@link AccessorData} */ private static void setElements( AccessorFloatData target, AccessorFloatData source) { int numElements = Math.min(target.getNumElements(), source.getNumElements()); int numComponents = Math.min( target.getNumComponentsPerElement(), source.getNumComponentsPerElement()); for (int e = 0; e < numElements; e++) { for (int c = 0; c < numComponents; c++) { float value = source.get(e, c); target.set(e, c, value); } } }
float component = get(e, c); sb.append(String.format(locale, format, component));