/**
   * Copies all of the field values from the passed nodes into our own node.
   *
   * @param node The node to copy
   * @throws IllegalArgumentException The node is not a compatible node
   */
  public void copy(VRMLNodeType node) {
    checkNodeType(node);

    try {
      int index;
      VRMLFieldData field;

      super.copy((VRMLTimeControlledNodeType) node);

      index = node.getFieldIndex("loop");
      field = node.getFieldValue(index);
      setLoop(field.booleanValue);

      index = node.getFieldIndex("repeatS");
      field = node.getFieldValue(index);
      vfRepeatS = field.booleanValue;

      index = node.getFieldIndex("repeatT");
      field = node.getFieldValue(index);
      vfRepeatT = field.booleanValue;

      index = node.getFieldIndex("speed");
      field = node.getFieldValue(index);
      setSpeed(field.floatValue);

      index = node.getFieldIndex("url");
      field = node.getFieldValue(index);
      setUrl(field.stringArrayValue, field.numElements);

    } catch (VRMLException ve) {
      throw new IllegalArgumentException(ve.getMessage());
    }
  }
  /**
   * Construct a new instance of this node based on the details from the given node. If the node is
   * not a group node, an exception will be thrown. It does not copy the children nodes, just this
   * node.
   *
   * @param node The node to copy
   * @throws IllegalArgumentException The node is not a Group node
   */
  public J3DTransform(VRMLNodeType node) {
    this();

    checkNodeType(node);

    copy((VRMLGroupingNodeType) node);

    try {
      int index = node.getFieldIndex("center");
      VRMLFieldData field = node.getFieldValue(index);

      vfCenter[0] = field.floatArrayValue[0];
      vfCenter[1] = field.floatArrayValue[1];
      vfCenter[2] = field.floatArrayValue[2];

      index = node.getFieldIndex("rotation");
      field = node.getFieldValue(index);

      vfRotation[0] = field.floatArrayValue[0];
      vfRotation[1] = field.floatArrayValue[1];
      vfRotation[2] = field.floatArrayValue[2];
      vfRotation[3] = field.floatArrayValue[3];

      index = node.getFieldIndex("scale");
      field = node.getFieldValue(index);

      vfScale[0] = field.floatArrayValue[0];
      vfScale[1] = field.floatArrayValue[1];
      vfScale[2] = field.floatArrayValue[2];

      index = node.getFieldIndex("scaleOrientation");
      field = node.getFieldValue(index);

      vfScaleOrientation[0] = field.floatArrayValue[0];
      vfScaleOrientation[1] = field.floatArrayValue[1];
      vfScaleOrientation[2] = field.floatArrayValue[2];
      vfScaleOrientation[3] = field.floatArrayValue[3];

      index = node.getFieldIndex("translation");
      field = node.getFieldValue(index);

      vfTranslation[0] = field.floatArrayValue[0];
      vfTranslation[1] = field.floatArrayValue[1];
      vfTranslation[2] = field.floatArrayValue[2];
    } catch (VRMLException ve) {
      throw new IllegalArgumentException(ve.getMessage());
    }
  }
Example #3
0
  /**
   * Construct a new instance of this node based on the details from the given node. If the node is
   * not a group node, an exception will be thrown.
   *
   * @param node The node to copy
   * @throws IllegalArgumentException The node is not a Group node
   */
  public BaseCADFace(VRMLNodeType node) {
    this();

    checkNodeType(node);

    try {

      int index = node.getFieldIndex("name");
      VRMLFieldData field = node.getFieldValue(index);

      field = node.getFieldValue(index);
      vfName = field.stringValue;
    } catch (VRMLException ve) {
      throw new IllegalArgumentException(ve.getMessage());
    }
  }
  /**
   * Construct a new instance of this node based on the details from the given node. If the node is
   * not the same type, an exception will be thrown.
   *
   * @param node The node to copy
   * @throws IllegalArgumentException Incorrect Node Type
   */
  protected BaseTextureProperties(VRMLNodeType node) {
    this();

    checkNodeType(node);

    try {
      int index = node.getFieldIndex("boundaryColor");
      VRMLFieldData field = node.getFieldValue(index);

      vfBoundaryColor[0] = field.floatArrayValue[0];
      vfBoundaryColor[1] = field.floatArrayValue[1];
      vfBoundaryColor[2] = field.floatArrayValue[2];
      vfBoundaryColor[3] = field.floatArrayValue[3];

      index = node.getFieldIndex("boundaryWidth");
      field = node.getFieldValue(index);
      vfBoundaryWidth = field.intValue;

      index = node.getFieldIndex("boundaryModeS");
      field = node.getFieldValue(index);
      vfBoundaryModeS = field.stringValue;

      index = node.getFieldIndex("boundaryModeT");
      field = node.getFieldValue(index);
      vfBoundaryModeT = field.stringValue;

      index = node.getFieldIndex("minificationFilter");
      field = node.getFieldValue(index);
      vfMinificationFilter = field.stringValue;

      index = node.getFieldIndex("maxificationFilter");
      field = node.getFieldValue(index);
      vfMinificationFilter = field.stringValue;

      index = node.getFieldIndex("generateMipMaps");
      field = node.getFieldValue(index);
      vfGenerateMipMaps = field.booleanValue;

      index = node.getFieldIndex("anisotropicMode");
      field = node.getFieldValue(index);
      vfAnisotropicMode = field.stringValue;

      index = node.getFieldIndex("anisotropicFilterDegree");
      field = node.getFieldValue(index);
      vfAnisotropicFilterDegree = field.floatValue;

    } catch (VRMLException ve) {
      throw new IllegalArgumentException(ve.getMessage());
    }
  }
 /** @see vrml.eai.field.EventOutMField#size */
 public int size() {
   if (isStored) return storedSize;
   else
     try {
       VRMLFieldData fieldData = theNode.getFieldValue(theFieldID);
       return fieldData.numElements;
     } catch (InvalidFieldException ife) {
       throw new RuntimeException("Error getting field size");
     }
 }
 /** @see vrml.eai.field.EventOutMFColor#getValue */
 public void getValue(float[] dest) {
   if (isStored) System.arraycopy(storedValue, 0, dest, 0, storedValue.length);
   else
     try {
       VRMLFieldData fieldData = theNode.getFieldValue(theFieldID);
       System.arraycopy(fieldData.floatArrayValue, 0, dest, 0, fieldData.floatArrayValue.length);
     } catch (InvalidFieldException ife) {
       throw new RuntimeException("Error getting field value");
     }
 }
 /** @see vrml.eai.field.EventOutMFColor#get1Value */
 public void get1Value(int index, float dest[]) {
   if (isStored) System.arraycopy(storedValue, index * 3, dest, 0, 3);
   else
     try {
       VRMLFieldData fieldData = theNode.getFieldValue(theFieldID);
       if (index < 0 || index >= fieldData.numElements) throw new ArrayIndexOutOfBoundsException();
       System.arraycopy(fieldData.floatArrayValue, index * 3, dest, 0, 3);
     } catch (InvalidFieldException ife) {
       throw new RuntimeException("Error getting field value");
     }
 }
  /**
   * Construct a new instance of this node based on the details from the given node. If the node is
   * not the same type, an exception will be thrown.
   *
   * @param node The node to copy
   * @throws IllegalArgumentException Incorrect Node Type
   */
  protected BaseMultiTexture(VRMLNodeType node) {
    this();

    checkNodeType(node);

    try {
      int index = node.getFieldIndex("mode");
      VRMLFieldData field = node.getFieldValue(index);
      if (field.numElements != 0) {
        vfMode = new String[field.numElements];
        System.arraycopy(field.stringArrayValue, 0, vfMode, 0, field.numElements);
      }

      index = node.getFieldIndex("function");
      field = node.getFieldValue(index);
      if (field.numElements != 0) {
        vfFunction = new String[field.numElements];
        System.arraycopy(field.stringArrayValue, 0, vfFunction, 0, field.numElements);
      }

      index = node.getFieldIndex("source");
      field = node.getFieldValue(index);
      if (field.numElements != 0) {
        vfSource = new String[field.numElements];
        System.arraycopy(field.stringArrayValue, 0, vfSource, 0, field.numElements);
      }

      index = node.getFieldIndex("color");
      field = node.getFieldValue(index);
      vfColor[0] = field.floatArrayValue[0];
      vfColor[1] = field.floatArrayValue[1];
      vfColor[2] = field.floatArrayValue[2];

      index = node.getFieldIndex("alpha");
      field = node.getFieldValue(index);
      vfAlpha = field.floatValue;

    } catch (VRMLException ve) {
      throw new IllegalArgumentException(ve.getMessage());
    }
  }
 /** @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");
     }
 }
 /** @see vrml.eai.field.EventOutSFColor#getValue */
 public void getValue(float dest[]) {
   if (isStored) {
     System.arraycopy(storedValue, 0, dest, 0, 4);
   } else
     try {
       VRMLFieldData value = theNode.getFieldValue(theFieldID);
       if (value.floatArrayValue == null) System.arraycopy(DEFAULT_FIELD_VALUE, 0, dest, 0, 3);
       else System.arraycopy(value.floatArrayValue, 0, dest, 0, 3);
     } catch (InvalidFieldException ife) {
       throw new RuntimeException("Error getting value.");
     }
 }
  /**
   * Construct a new instance of this node based on the details from the given node. If the node is
   * not the same type, an exception will be thrown.
   *
   * @param node The node to copy
   * @throws IllegalArgumentException The node is not the same type
   */
  public BaseSphereSensor(VRMLNodeType node) {
    this();

    checkNodeType(node);

    copy((VRMLDragSensorNodeType) node);

    try {
      int index = node.getFieldIndex("offset");
      VRMLFieldData field = node.getFieldValue(index);

      vfOffset[0] = field.floatArrayValue[0];
      vfOffset[1] = field.floatArrayValue[1];
      vfOffset[2] = field.floatArrayValue[2];
      vfOffset[3] = field.floatArrayValue[3];

    } catch (VRMLException ve) {
      throw new IllegalArgumentException(ve.getMessage());
    }
  }
 /** @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()
             + ".");
   }
 }