예제 #1
0
  /**
   * Sets this camera's position to a given point.
   *
   * @param position A <code>Vector3D</code> describing the position at which to set the camera.
   * @throws IllegalArgumentException If <code>position</code> is <code>null</code>.
   */
  public void setPosition(Vector3D position) {
    // store current focus point
    Vector3D focusPoint = getFocusPoint();

    // set position
    super.setPosition(position);

    // if focus is locked, look at original focus point
    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);
  }
예제 #3
0
  /**
   * Rotates and moves the camera in order to follow a given point from a given distance. This
   * method is similar to the <code>lookAt()</code> method, except it also adjusts position. When
   * needed, the camera will be moved such that the distance between the camera and <code>point
   * </code> is less than or equal to <code>distance</code>.
   *
   * @param point The point to look at / follow.
   * @param distance The maximum allowed distance between the camera and the given point.
   * @param up A vector describing the orientation of the desired local y-axis.
   */
  public void follow(Vector3D point, double distance, Vector3D up) {
    // look at the given point
    lookAt(point, up);

    // further than allowed follow distance?
    if (focusDepth > distance) {
      // fix position
      Vector3D delta = new Vector3D(getFocusVector(), focusDepth - distance);
      super.setPosition(getPosition().add(delta));

      // set focus depth
      setFocusDepth(distance);
    }
  }