/** * Write the value of the event out to the given array. * * @param vec The array to be filled in where<br> * vec[i][0] = X<br> * vec[i][1] = Y<br> * vec[i][2] = Z * @exception ArrayIndexOutOfBoundsException The provided array was too small */ public void getValue(float[][] vec) { if (storedOutput) { ArrayUtils.raise3(storedOutputValue, storedOutputValue.length / 3, vec); } else { checkReadAccess(); VRMLFieldData data = theNode.getFieldValue(fieldIndex); if (data.numElements != 0) ArrayUtils.raise3(data.floatArrayValue, data.numElements, vec); } }
/** @see vrml.eai.field.EventOutMFColor#getValue */ public void getValue(float[][] dest) { if (isStored) ArrayUtils.raise3(storedValue, storedSize, dest); else try { // Not using ArrayUtils because we need to allocate the array. VRMLFieldData fieldData = theNode.getFieldValue(theFieldID); int arraySize = fieldData.numElements; ArrayUtils.raise3(fieldData.floatArrayValue, arraySize, dest); } catch (InvalidFieldException ife) { throw new RuntimeException("Error getting field value"); } }
/** Store a value in this EventIn as a place holder for the buffering system. */ private void storeValue(float[][] newValue) { if (newValue != null) { if (storedValue == null || storedValue.length != (newValue.length * 4)) storedValue = new float[newValue.length * 4]; ArrayUtils.flatten4(newValue, newValue.length, storedValue); } else storedValue = null; hasStoredValue = true; }
/** @see vrml.eai.field.EventOutMFColor#getValue */ public float[][] getValue() { float result[][] = new float[size()][]; for (int counter = 0; counter < result.length; counter++) result[counter] = new float[3]; if (isStored) { ArrayUtils.raise3(storedValue, storedSize, result); return result; } try { VRMLFieldData fieldData = theNode.getFieldValue(theFieldID); ArrayUtils.raise3(fieldData.floatArrayValue, fieldData.numElements, result); return result; } catch (InvalidFieldException ife) { throw new RuntimeException( "InvalidFieldException Error getting field value. " + "Was looking for fieldID" + theFieldID + " in a " + theNode.getClass().getName() + "."); } }
/** * Set the value of the array of 3D vectors. Input is an array of doubles If value[i] does not * contain at least three values it will generate an ArrayIndexOutOfBoundsException. If value[i] * contains more than three items only the first three values will be used and the rest ignored. * * <p>If one or more of the values for value[i] are null then the resulting event that is sent to * the VRML scenegraph is implementation dependent but no error indicator will be set here. * * @param numVec The number of items to copy from the array * @param value The array of vec2f values where<br> * value[i][0] = X<br> * value[i][1] = Y<br> * value[i][2] = Z * @exception ArrayIndexOutOfBoundsException A value did not contain at least three values for the * vector definition. */ public void setValue(int numVec, float[][] value) { checkWriteAccess(); MFVec3fWrapper queuedElement = this; // Input and output buffers do not mix and further don't overwrite // set1Value calls if (isSetOneValue || storedInput || storedOutput) { queuedElement = new MFVec3fWrapper(theNode, fieldIndex, theEventQueue, theEventAdapterFactory); } queuedElement.storedInput = true; if (queuedElement.storedInputValue == null || queuedElement.storedInputValue.length != numVec * 3) queuedElement.storedInputValue = new float[numVec * 3]; ArrayUtils.flatten3(value, numVec, queuedElement.storedInputValue); queuedElement.storedInputLength = numVec * 3; theEventQueue.processEvent(queuedElement); }
/** * Get the vec values used in this field and copy them into the user provided array. * * @param vecs The array to copy values to */ public void getValue(float[][] vecs) { if (numElements > 0) ArrayUtils.raise4(data, numElements, vecs); }
/** * Construct a new field based on all the given 4D array of values. * * @param vecs The vec values to use */ public ConstMFRotation(float vecs[][]) { numElements = vecs.length; data = new float[vecs.length * 4]; ArrayUtils.flatten4(vecs, vecs.length, data); }