コード例 #1
0
 protected void onResetHeadingPitchRoll(ViewInputAttributes.ActionAttributes actionAttribs) {
   View view = this.getView();
   if (view == null) // include this test to ensure any derived implementation performs it
   {
     return;
   }
   double smoothing = 0.95;
   this.gotoAnimControl.put(
       VIEW_ANIM_HEADING,
       new RotateToAngleAnimator(
           view.getHeading(),
           Angle.ZERO,
           smoothing,
           ViewPropertyAccessor.createHeadingAccessor(view)));
   this.gotoAnimControl.put(
       VIEW_ANIM_PITCH,
       new RotateToAngleAnimator(
           view.getPitch(),
           Angle.POS90,
           smoothing,
           ViewPropertyAccessor.createPitchAccessor(view)));
   this.gotoAnimControl.put(
       VIEW_ANIM_ROLL,
       new RotateToAngleAnimator(
           view.getPitch(), Angle.ZERO, smoothing, ViewPropertyAccessor.createRollAccessor(view)));
   view.firePropertyChange(AVKey.VIEW, null, view);
 }
コード例 #2
0
  /**
   * Set the roll in a view.
   *
   * @param view View to modify.
   * @param animControl Animator controller for the view.
   * @param roll new roll value.
   * @param attrib action that caused the roll to change.
   */
  protected void setRoll(
      View view,
      AnimationController animControl,
      Angle roll,
      ViewInputAttributes.ActionAttributes attrib) {
    double smoothing = attrib.getSmoothingValue();
    if (!(attrib.isEnableSmoothing() && this.isEnableSmoothing())) smoothing = 0.0;

    AngleAnimator angleAnimator =
        new RotateToAngleAnimator(
            view.getRoll(), roll, smoothing, ViewPropertyAccessor.createRollAccessor(view));
    animControl.put(VIEW_ANIM_ROLL, angleAnimator);
  }
コード例 #3
0
  protected void onResetPitch(ViewInputAttributes.ActionAttributes actionAttribs) {

    View view = this.getView();
    if (view == null) // include this test to ensure any derived implementation performs it
    {
      return;
    }
    double smoothing = actionAttribs.getSmoothingValue();
    if (!(actionAttribs.isEnableSmoothing() && this.isEnableSmoothing())) smoothing = 0.0;
    this.gotoAnimControl.put(
        VIEW_ANIM_PITCH,
        new RotateToAngleAnimator(
            view.getPitch(),
            Angle.POS90,
            smoothing,
            ViewPropertyAccessor.createPitchAccessor(view)));
    view.firePropertyChange(AVKey.VIEW, null, view);
  }
コード例 #4
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);
  }