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()); }
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); }