示例#1
0
  /**
   * Rotates this camera by a given amount. If <code>relative</code> is set to <code>true</code>
   * then the rotation will be performed relative to this camera's current orientation. Otherwise,
   * the rotation will be performed relative to the world coordinate system.
   *
   * <p>If this camera's focus is locked, then only rotation about the z axis (roll) will be
   * performed.
   *
   * @param rotation The amount of rotation to be applied to this camera.
   * @param relative A boolean flag stating whether the rotation performed should be relative to
   *     this camera's current orientation.
   */
  public void rotate(Rotation rotation, boolean relative) {
    // store current focus point
    Vector3D focusPoint = getFocusPoint();

    // perform rotation
    if (relative) super.setOrientation(getOrientation().append(rotation));
    else super.setOrientation(rotation.append(getOrientation()));

    // if focus is locked, look at the point of focus
    if (focusLocked) lookAt(focusPoint);
  }
示例#2
0
  /**
   * Rotates this camera by a given amount around a given point. The rotation will be performed
   * relative to the world coordinate system. If the <cod>reorient</code> flag is set to <code>true
   * </code>, then the rotation will be applied as a standard rotational transformation would;
   * altering this camera's orientation. If set to <code>false</code>, this camera's orientation
   * will remain unchanged as the rotation is performed.
   *
   * <p>Note that the camera will maintain focus if the camera's focus is locked.
   *
   * @param rotation The amount of rotation to be applied to this camera.
   * @param point The point, in the world coordinate system, about which the rotation will occur.
   * @param reorient A flag stating whether or not to alter this camera's orientation as with the
   *     applied rotation.
   */
  public void rotate(Rotation rotation, Vector3D point, boolean reorient) {
    // store current focus point
    Vector3D focusPoint = getFocusPoint();

    // find vector between given point and camera, in local coordinates
    Vector3D vect = getPosition().subtract(point);

    // move camera to given point
    super.setPosition(point);

    // rotate camera for standard rotation
    if (reorient) super.setOrientation(rotation.append(getOrientation()));

    // rotate vector
    vect = vect.rotate(rotation);

    // move back to proper position
    super.setPosition(getPosition().add(vect));

    // if focus is locked, look at original focus point
    if (focusLocked) lookAt(focusPoint);
  }