Exemplo n.º 1
0
 /** @see org.web3d.x3d.sai.MFVec3f#insertValue(int, float[]) */
 public void insertValue(int index, float[] value) throws ArrayIndexOutOfBoundsException {
   checkReadAccess();
   checkWriteAccess();
   synchronized (theEventQueue.eventLock) {
     MFVec3fWrapper queuedElement = (MFVec3fWrapper) theEventQueue.getLast(this);
     boolean newEvent = false;
     if (queuedElement == null || !queuedElement.isSetOneValue) {
       // Input and output buffers do not mix
       if (!storedInput && !storedOutput) {
         queuedElement = this;
         loadInputValue();
         isSetOneValue = true;
       } else {
         queuedElement =
             new MFVec3fWrapper(theNode, fieldIndex, theEventQueue, theEventAdapterFactory, true);
         queuedElement.isSetOneValue = true;
       }
       newEvent = true;
     }
     queuedElement.ensureArraySize(queuedElement.storedInputLength + 3);
     System.arraycopy(
         queuedElement.storedInputValue,
         index * 3,
         queuedElement.storedInputValue,
         index * 3 + 3,
         queuedElement.storedInputLength - index * 3);
     queuedElement.storedInputValue[index * 3] = value[0];
     queuedElement.storedInputValue[index * 3 + 1] = value[1];
     queuedElement.storedInputValue[index * 3 + 2] = value[2];
     queuedElement.storedInputLength += 3;
     if (newEvent) theEventQueue.processEvent(queuedElement);
   }
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
 /** @see org.web3d.x3d.sai.MFBool#removeValue(int) */
 public void removeValue(int index) throws ArrayIndexOutOfBoundsException {
   checkReadAccess();
   checkWriteAccess();
   synchronized (theEventQueue.eventLock) {
     MFVec3fWrapper queuedElement = (MFVec3fWrapper) theEventQueue.getLast(this);
     boolean newEvent = false;
     if (queuedElement == null || !queuedElement.isSetOneValue) {
       // Input and output buffers do not mix
       if (!storedInput && !storedOutput) {
         queuedElement = this;
         loadInputValue();
         isSetOneValue = true;
       } else {
         queuedElement =
             new MFVec3fWrapper(theNode, fieldIndex, theEventQueue, theEventAdapterFactory, true);
         queuedElement.isSetOneValue = true;
       }
       newEvent = true;
     }
     if (queuedElement.storedInputLength > 0) {
       if (index * 3 + 3 < queuedElement.storedInputLength)
         System.arraycopy(
             queuedElement.storedInputValue,
             index * 3 + 3,
             queuedElement.storedInputValue,
             index * 3,
             queuedElement.storedInputLength - index * 3 - 3);
       queuedElement.storedInputLength -= 3;
       if (newEvent) theEventQueue.processEvent(queuedElement);
     } else {
       // Free up the buffer before throwing the exception
       if (newEvent) queuedElement.isSetOneValue = false;
       throw new ArrayIndexOutOfBoundsException();
     }
   }
 }