/** * 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); } } }
/** * Returns the value of the specified component of the specified element * * @param elementIndex The element index * @param componentIndex The component index * @return The value * @throws IndexOutOfBoundsException If the given indices cause the * underlying buffer to be accessed out of bounds */ public float get(int elementIndex, int componentIndex) { int byteIndex = getByteIndex(elementIndex, componentIndex); return getBufferViewByteBuffer().getFloat(byteIndex); }
/** * Set the value of the specified component * * @param globalComponentIndex The global component index * @param value The value * @throws IndexOutOfBoundsException If the given index causes the * underlying buffer to be accessed out of bounds */ public void set(int globalComponentIndex, float value) { int elementIndex = globalComponentIndex / getNumComponentsPerElement(); int componentIndex = globalComponentIndex % getNumComponentsPerElement(); set(elementIndex, componentIndex, value); }
/** * 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; }
int numElements = morphed.getNumElements(); for (int e = 0; e < numElements; e++) float r = base.get(e, c); for (int i = 0; i < weights.length; i++) float d = target.get(e, c); r += w * d; morphed.set(e, c, r);
InterpolatorType interpolatorType) int numKeyElements = timeData.getNumElements(); float keys[] = new float[numKeyElements]; for (int e=0; e<numKeyElements; e++) keys[e] = timeData.get(e); outputData.getTotalNumComponents(); int numComponentsPerElement = totalNumValueComponents / numKeyElements; values[e][c] = outputData.get(globalIndex);
@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; }
AccessorDatas.validateFloatType(componentType); AccessorDatas.validateCapacity(byteOffset, getNumElements(), getByteStridePerElement(), bufferViewByteBuffer.capacity());
@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; }
/** * Creates an {@link AccessorFloatData} for the given {@link AccessorModel} * * @param accessorModel The {@link AccessorModel} * @param bufferViewByteBuffer The byte buffer of the * {@link BufferViewModel} referenced by the {@link AccessorModel} * @return The {@link AccessorFloatData} * @throws NullPointerException If any argument is <code>null</code> * @throws IllegalArgumentException If the */ private static AccessorFloatData createFloat( AccessorModel accessorModel, ByteBuffer bufferViewByteBuffer) { return new AccessorFloatData(accessorModel.getComponentType(), bufferViewByteBuffer, accessorModel.getByteOffset(), accessorModel.getCount(), accessorModel.getElementType().getNumComponents(), accessorModel.getByteStride()); }
(AccessorFloatData) accessorData; String accessorDataString = accessorFloatData.createString( Locale.ENGLISH, "%10.5f", elementsPerRow); return accessorDataString;
(AccessorFloatData) accessorData; return NumberArrays.asNumbers( accessorFloatData.computeMin());
(AccessorFloatData) accessorData; return NumberArrays.asNumbers( accessorFloatData.computeMax());
/** * 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);
return new AccessorFloatData( componentType, bufferViewData, byteOffset, count, numComponentsPerElement, byteStride);
AccessorFloatData sparseValuesAccessorData) int numElements = denseAccessorData.getNumElements(); int numComponentsPerElement = denseAccessorData.getNumComponentsPerElement(); float value = baseAccessorData.get(e, c); denseAccessorData.set(e, c, value); for (int c = 0; c < numComponentsPerElement; c++) float substitution = sparseValuesAccessorData.get(i, c); denseAccessorData.set(targetElementIndex, c, substitution);
int nc = getNumComponentsPerElement(); sb.append("["); for (int e = 0; e < getNumElements(); e++) float component = get(e, c); sb.append(String.format(locale, format, component));
/** * Set the value of the specified component of the specified element * * @param elementIndex The element index * @param componentIndex The component index * @param value The value * @throws IndexOutOfBoundsException If the given indices cause the * underlying buffer to be accessed out of bounds */ public void set(int elementIndex, int componentIndex, float value) { int byteIndex = getByteIndex(elementIndex, componentIndex); getBufferViewByteBuffer().putFloat(byteIndex, value); }