This document describes what is required in order to move application code from the old View/StateIterator Architecture in World Wind, to the new View/Animator interface architecture in World Wind. The View and Animation system was rearchitected to provide a framework for supporting varying View/Navigation paradigms. Prior to this rearchitecture, OrbitView was the only view/navigation paradigm provided with World Wind. Now there is a fly view paradigm(gov.nasa.worldwind.view.firstperson.BasicFlyView), and the system has been architected to support derivations of existing views, and instances of completely new views.
The first section describes the change to the View interface. The second section is a list of old methods for creating view state iteratations, and the matching methods in the new View/Animator interface. The final section is a case study example from gov.nasa.worldwind.applications.sar.
Changes to the View interface
The View interface has changed to :
Remove interface methods that were specific to the OrbitView implementation.
setDetectCollisions, hadCollisions, and isDetectCollisions are no longer specified in the View interface. The BasicOrbitView View implementation still has those methods.
Near and Far Distance setters/getters
Remove the methods for setting near and far distance.
Views by default control the near and far distance. When an application needs to specify clip distances, it can derive a new View from BasicView, BasicOrbitView, or BasicFlyView, overriding the protected methods computeNearClipDistance(), and computeFarClipDistance(). This means the general View interface does not provide set capability for the near and far clip distances. Note that these are the methods that do not take any parameters. They are called from the doApply() method that sets up the modelview and projection matrices.
Remove the getAutoNearClipDistance(), and getAutoFarClipDistance()
View implementations now return the near and far clip distances in getNearClipDistance() and getFarClipDistance().
Remove methods for setting and starting Iterators, and for determining whether an iterator is operational.
Iterators have been replaced by Animators which reside in the gov.nasa.worldwind.animation package. See the next section in this document: Old/New Method Mappings for View Animation for more information.
The Iterator methods are replaced by Animator methods:
stopAnimations() will stop running all View Animators.
IsAnimating() returns true if there are active animations, false otherwise.
Added a method for getting the center point of the globe in the view: vec4 View.getCenterPoint().
Added a method for getting the Globe used in the view: getGlobe().
Added a method for getting the ViewInputHandler : getViewInputHandler(). The architecture has changed in that the ViewInputHandler used to be created and owned by the AWTInputHandler. Now it is created and owned by the View.
Added getViewPropertyLimits() for getting a reference to the View's limits.
Added copyViewState(View view) to support switching from one View implementation to another.
Old/New Method Mappings for View Animation
There is a new method in the View interface :
void goTo(Position lookAtPos, double elevation);
This method can be used without knowing the underlying View implementation if that application simply wants the view to be looking at a particular location.
From the FlyToOrbitViewStateIterator class:
|
FlyToOrbitViewStateIterator Method |
Corresponding BasicOrbitView method |
|
createPanToIterator(OrbitView orbitView, Globe globe,Position center, Angle, heading, Angle pitch, double zoom) |
addPanToAnimator(Position center,Angle heading, Angle pitch, double zoom) |
|
createPanToIterator(OrbitView orbitView, Globe globe, Position center, Angle heading, Angle pitch, double zoom, boolean endCenterOnSurface) |
addPanToAnimator(Position center, Angle heading, Angle pitch, double zoom, boolean endCenterOnSurface) |
|
createPanToIterator(Globe globe, Position beginCenter, Position endCenter, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, double beginZoom, double endZoom) |
addPanToAnimator(Position beginCenter, Position endCenter, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, double beginZoom, double endZoom) |
|
CreatePanToIterator(Globe globe, Position beginCenter, Position endCenter, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, double beginZoom, double endZoom, boolean endCenterOnSurface) |
AddPanToAnimator(Position beginCenter, Position endCenter, Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch, double beginZoom, double endZoom, boolean endCenterOnSurface) |
From the ScheduledViewStateIterator class:
|
ScheduledViewStateIterator Method |
Corresponding BasicOrbitView method |
|
createHeadingPitchIterator(OrbitView view, Angle beginHeding, Angle endHeading, Angle beginPitch, Angle endPitch); |
addHeadingPitchAnimator(Angle beginHeading, Angle endHeading, Angle beginPitch, Angle endPitch) |
|
createHeadingIterator(OrbitView view, Angle beginHeding, Angle endHeading) |
addHeadingAnimator(Angle beginHeading, Angle endHeading) |
|
createHeadingIterator(OrbitView view, Angle beginHeding, Angle endHeading) |
addPitchAnimator(Angle beginPitch, Angle endPitch) |
If your code uses an EyePositionIterator, you can simply replace its construction and application to the View, with the
BasicOrbitView method :
BasicOrbitView.addEyePositionAnimator(long timeToIterate, Position beginPosition, Position endPosition)
To stop and motion that is associated with animations in the View use:
View.stopAnimations()
To determine if a View is currently running any animations use:
View.isAnimating()
An example of what is required of an application to adapt to the new View/Animator Interface architecture
This section shows how the Search and Rescue(SAR) application gov.nasa.worldwind.applications.sar was modified to use the new View/Animator interface architecture. In the SAR application, there are 3 uses of :
FlyToOrbitViewStateIterator.createPanToIterator
view.applyStateIterator
These are easily replaced with calls to :
OrbitViewInputHandler.addPanToAnimator
In the AnalysisPanel class there are 2 usages of:
FlyToOrbitViewStateIterator.createPanToIterator
view.applyStateIterator
Line 369 in the method updateView:
is changed from :
view.applyStateIterator(FlyToOrbitViewStateIterator.createPanToIterator(view, this.wwd.getModel().getGlobe(),groundPos, initialHeading, initialPitch, initialZoom, true));
To :
((BasicOrbitView) view).addPanToAnimator(groundPos, initialHeading, initialPitch, initialZoom, true);
Line 424 in updateView:
is changed from :
view.applyStateIterator(FlyToOrbitViewStateIterator.createPanToIterator( view, this.wwd.getModel().getGlobe(), addpos, heading, pitch, zoom));
To:
((BasicOrbitView) view).addPanToAnimator( pos, heading, pitch, zoom, false);
In the TrackController class there is one usage of :
FlyToOrbitViewStateIterator.createPanToIterator
view.applyStateIterator
Line 335 in the method moveToTrack :
is changed from:
view.applyStateIterator(FlyToOrbitViewStateIterator.createPanToIterator( view, this.wwd.getModel().getGlobe(), pos, view.getHeading(), Angle.ZERO, 10000, true))
To:
((BasicOrbitView) view).addPanToAnimator(pos, view.getHeading(), Angle.ZERO, 10000, true);