コード例 #1
0
  public void goTo(Position lookAtPos, double distance) {

    Globe globe = this.getView().getGlobe();
    BasicFlyView view = (BasicFlyView) this.getView();

    Position lookFromPos =
        new Position(
            lookAtPos,
            globe.getElevation(lookAtPos.getLatitude(), lookAtPos.getLongitude()) + distance);

    // TODO: scale on mid-altitude?
    final long MIN_LENGTH_MILLIS = 4000;
    final long MAX_LENGTH_MILLIS = 16000;
    long timeToMove =
        AnimationSupport.getScaledTimeMillisecs(
            view.getEyePosition(), lookFromPos, MIN_LENGTH_MILLIS, MAX_LENGTH_MILLIS);
    FlyToFlyViewAnimator panAnimator =
        FlyToFlyViewAnimator.createFlyToFlyViewAnimator(
            view,
            view.getEyePosition(),
            lookFromPos,
            view.getHeading(),
            Angle.ZERO,
            view.getPitch(),
            Angle.ZERO,
            view.getEyePosition().getElevation(),
            lookFromPos.getElevation(),
            timeToMove,
            WorldWind.ABSOLUTE);

    this.gotoAnimControl.put(VIEW_ANIM_PAN, panAnimator);

    this.getView().firePropertyChange(AVKey.VIEW, null, this.getView());
  }
コード例 #2
0
  protected void onVerticalTranslate(
      double translateChange,
      double totalTranslateChange,
      ViewInputAttributes.DeviceAttributes deviceAttributes,
      ViewInputAttributes.ActionAttributes actionAttribs) {
    this.stopGoToAnimators();
    double elevChange =
        -(totalTranslateChange * getScaleValueElevation(deviceAttributes, actionAttribs));
    View view = this.getView();
    Position position = view.getEyePosition();
    Position newPos = new Position(position, position.getElevation() + (elevChange));
    this.setEyePosition(uiAnimControl, view, newPos, actionAttribs);

    view.firePropertyChange(AVKey.VIEW, null, view);
  }
コード例 #3
0
  protected void setEyePosition(
      AnimationController animControl,
      View view,
      Position position,
      ViewInputAttributes.ActionAttributes attrib) {

    MoveToPositionAnimator posAnimator =
        (MoveToPositionAnimator) animControl.get(VIEW_ANIM_POSITION);

    double smoothing = attrib.getSmoothingValue();
    if (!(attrib.isEnableSmoothing() && this.isEnableSmoothing())) smoothing = 0.0;

    if (smoothing != 0.0) {

      double elevation =
          ((FlyViewLimits) view.getViewPropertyLimits())
              .limitEyeElevation(position, view.getGlobe());
      if (elevation != position.getElevation()) {
        position = new Position(position, elevation);
      }
      if (posAnimator == null) {
        posAnimator =
            new MoveToPositionAnimator(
                view.getEyePosition(),
                position,
                smoothing,
                OrbitViewPropertyAccessor.createEyePositionAccessor(view));
        animControl.put(VIEW_ANIM_POSITION, posAnimator);
      } else {
        posAnimator.setEnd(position);
        posAnimator.start();
      }
    }
    view.firePropertyChange(AVKey.VIEW, null, view);
  }
コード例 #4
0
  public void lookAt(Position lookAtPos, long timeToMove) {
    BasicFlyView view = (BasicFlyView) this.getView();
    Vec4 lookDirection;
    double distanceToSurface;
    Vec4 currentLookAtPt = view.getCenterPoint();
    Position newPosition;
    if (currentLookAtPt == null) {
      view.getGlobe().computePointFromPosition(lookAtPos);
      double elevAtLookAtPos =
          view.getGlobe().getElevation(lookAtPos.getLatitude(), lookAtPos.getLongitude());
      newPosition = new Position(lookAtPos, elevAtLookAtPos + 10000);
    } else {
      Vec4 currentEyePt = view.getEyePoint();
      distanceToSurface = currentEyePt.distanceTo3(currentLookAtPt);
      lookDirection = currentLookAtPt.subtract3(currentEyePt).normalize3();
      Vec4 newLookAtPt = view.getGlobe().computePointFromPosition(lookAtPos);
      Vec4 flyToPoint = newLookAtPt.add3(lookDirection.multiply3(-distanceToSurface));
      newPosition = view.getGlobe().computePositionFromPoint(flyToPoint);
    }

    ViewUtil.ViewState viewCoords = view.getViewState(newPosition, lookAtPos);

    FlyToFlyViewAnimator panAnimator =
        FlyToFlyViewAnimator.createFlyToFlyViewAnimator(
            view,
            view.getEyePosition(),
            newPosition,
            view.getHeading(),
            viewCoords.getHeading(),
            view.getPitch(),
            viewCoords.getPitch(),
            view.getEyePosition().getElevation(),
            viewCoords.getPosition().getElevation(),
            timeToMove,
            WorldWind.ABSOLUTE);

    this.gotoAnimControl.put(VIEW_ANIM_PAN, panAnimator);
    this.getView().firePropertyChange(AVKey.VIEW, null, this.getView());

    view.firePropertyChange(AVKey.VIEW, null, view);
  }
コード例 #5
0
  protected void onMoveTo(
      Position focalPosition,
      ViewInputAttributes.DeviceAttributes deviceAttributes,
      ViewInputAttributes.ActionAttributes actionAttribs) {
    BasicFlyView view = (BasicFlyView) this.getView();
    if (view == null) // include this test to ensure any derived implementation performs it
    {
      return;
    }

    // We're treating a speed parameter as smoothing here. A greater speed results in greater
    // smoothing and
    // slower response. Therefore the min speed used at lower altitudes ought to be *greater* than
    // the max
    // speed used at higher altitudes.
    double smoothing = this.getScaleValueElevation(deviceAttributes, actionAttribs);
    if (!actionAttribs.isEnableSmoothing()) smoothing = 0.0;

    Vec4 currentLookAtPt = view.getCenterPoint();
    if (currentLookAtPt == null) {
      currentLookAtPt = view.getGlobe().computePointFromPosition(focalPosition);
    }

    Vec4 currentEyePt = view.getEyePoint();
    double distanceToSurface = currentEyePt.distanceTo3(currentLookAtPt);
    Vec4 lookDirection = currentEyePt.subtract3(currentLookAtPt).normalize3();
    Vec4 newLookAtPt = view.getGlobe().computePointFromPosition(focalPosition);
    Vec4 flyToPoint = newLookAtPt.add3(lookDirection.multiply3(distanceToSurface));

    Position newPosition = view.getGlobe().computePositionFromPoint(flyToPoint);

    ViewUtil.ViewState viewCoords = view.getViewState(newPosition, focalPosition);

    this.stopAnimators();
    this.gotoAnimControl.put(
        VIEW_ANIM_HEADING,
        new RotateToAngleAnimator(
            view.getHeading(),
            viewCoords.getHeading(),
            smoothing,
            ViewPropertyAccessor.createHeadingAccessor(view)));
    this.gotoAnimControl.put(
        VIEW_ANIM_PITCH,
        new RotateToAngleAnimator(
            view.getPitch(),
            viewCoords.getPitch(),
            smoothing,
            ViewPropertyAccessor.createPitchAccessor(view)));

    double elevation =
        ((FlyViewLimits) view.getViewPropertyLimits())
            .limitEyeElevation(newPosition, view.getGlobe());
    if (elevation != newPosition.getElevation()) {
      newPosition = new Position(newPosition, elevation);
    }
    this.gotoAnimControl.put(
        VIEW_ANIM_POSITION,
        new MoveToPositionAnimator(
            view.getEyePosition(),
            newPosition,
            smoothing,
            ViewPropertyAccessor.createEyePositionAccessor(view)));

    view.firePropertyChange(AVKey.VIEW, null, view);
  }