Пример #1
0
  /**
   * Notification that this sensor has just been clicked on to start a drag action.
   *
   * @param hitPoint Where the input device intersected the object sensor
   * @param position Where the sensor origin is in local coordinates
   */
  public void notifySensorDragStart(float[] hitPoint, float[] location) {

    super.notifySensorDragStart(hitPoint, location);

    dragRadius =
        (float)
            Math.sqrt(
                hitPoint[0] * hitPoint[0] + hitPoint[1] * hitPoint[1] + hitPoint[2] * hitPoint[2]);

    initialNormal[0] = hitPoint[0] / dragRadius;
    initialNormal[1] = hitPoint[1] / dragRadius;
    initialNormal[2] = hitPoint[2] / dragRadius;
  }
Пример #2
0
  /**
   * Notification that this sensor has finished a drag action.
   *
   * @param position Where the sensor origin is in local coordinates
   * @param direction Vector showing the direction the sensor is pointing
   */
  public void notifySensorDragEnd(float[] position, float[] direction) {

    super.notifySensorDragEnd(position, direction);

    if (vfAutoOffset) {
      vfOffset[0] = vfRotationChanged[0];
      vfOffset[1] = vfRotationChanged[1];
      vfOffset[2] = vfRotationChanged[2];
      vfOffset[3] = vfRotationChanged[3];

      hasChanged[FIELD_OFFSET] = true;
      fireFieldChanged(FIELD_OFFSET);
    }
  }
Пример #3
0
  /**
   * Set the value of the field at the given index as a float array. This is be used to set SFVec2f
   * and SFVec3f field types.
   *
   * @param index The index of destination field to set
   * @param value The new value to use for the node
   * @param numValid The number of valid values to copy from the array
   * @throws InvalidFieldException The field index is not known
   */
  public void setValue(int index, float[] value, int numValid)
      throws InvalidFieldException, InvalidFieldValueException {

    switch (index) {
      case FIELD_OFFSET:
        vfOffset[0] = value[0];
        vfOffset[1] = value[1];
        vfOffset[2] = value[2];
        vfOffset[3] = value[3];
        break;

      default:
        super.setValue(index, value, numValid);
    }

    if (!inSetup) {
      hasChanged[index] = true;
      fireFieldChanged(index);
    }
  }
Пример #4
0
  /**
   * Send a routed value from this node to the given destination node. The route should use the
   * appropriate setValue() method of the destination node. It should not attempt to cast the node
   * up to a higher level. Routing should also follow the standard rules for the loop breaking and
   * other appropriate rules for the specification.
   *
   * @param time The time that this route occurred (not necessarily epoch time. Should be treated as
   *     a relative value only)
   * @param srcIndex The index of the field in this node that the value should be sent from
   * @param destNode The node reference that we will be sending the value to
   * @param destIndex The index of the field in the destination node that the value should be sent
   *     to.
   */
  public void sendRoute(double time, int srcIndex, VRMLNodeType destNode, int destIndex) {

    // Simple impl for now.  ignores time and looping

    try {
      switch (srcIndex) {
        case FIELD_ROTATION_CHANGED:
          destNode.setValue(destIndex, vfRotationChanged, 4);
          break;

        case FIELD_OFFSET:
          destNode.setValue(destIndex, vfOffset, 4);
          break;

        default:
          super.sendRoute(time, srcIndex, destNode, destIndex);
      }
    } catch (InvalidFieldException ife) {
      System.err.println("BaseSphereSensor.sendRoute: No field! " + srcIndex);
      ife.printStackTrace();
    } catch (InvalidFieldValueException ifve) {
      System.err.println("BaseSphereSensor.sendRoute: Invalid field value: " + ifve.getMessage());
    }
  }
Пример #5
0
  /**
   * Get the value of a field. If the field is a primitive type, it will return a class representing
   * the value. For arrays or nodes it will return the instance directly.
   *
   * @param index The index of the field to change.
   * @return The class representing the field value
   * @throws InvalidFieldException The field index is not known
   */
  public VRMLFieldData getFieldValue(int index) throws InvalidFieldException {
    VRMLFieldData fieldData = fieldLocalData.get();

    switch (index) {
      case FIELD_ROTATION_CHANGED:
        fieldData.clear();
        fieldData.floatArrayValue = vfRotationChanged;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      case FIELD_OFFSET:
        fieldData.clear();
        fieldData.floatArrayValue = vfOffset;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      default:
        super.getFieldValue(index);
    }

    return fieldData;
  }