Skip to content

Commit b1fe177

Browse files
committed
Simplify camera to look at transformation logic.
1 parent 56c4e8d commit b1fe177

18 files changed

+288
-314
lines changed

worldwind-examples/src/main/java/gov/nasa/worldwindx/GeneralGlobeActivity.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,8 @@ public void onNavigatorEvent(WorldWindow wwd, NavigatorEvent event) {
8181
// Update the status overlay views whenever the navigator stops moving,
8282
// and also it is moving but at an (arbitrary) maximum refresh rate of 20 Hz.
8383
if (eventAction == WorldWind.NAVIGATOR_STOPPED || elapsedTime > 50) {
84-
// Pick terrain located behind the viewport center point
85-
PickedObject terrainPickedObject = wwd.pick(wwd.getViewport().width / 2f, wwd.getViewport().height / 2f).terrainPickedObject();
86-
Position terrainPosition = terrainPickedObject != null ? terrainPickedObject.getTerrainPosition() : null;
87-
8884
// Get the current camera state to apply to the overlays
89-
event.getCamera().getAsLookAt(wwd.getGlobe(), wwd.getVerticalExaggeration(), terrainPosition, lookAt);
85+
wwd.cameraAsLookAt(lookAt);
9086

9187
// Update the overlays
9288
updateOverlayContents(lookAt, event.getCamera());

worldwind-examples/src/main/java/gov/nasa/worldwindx/OmnidirectionalSightlineActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected void onCreate(Bundle savedInstanceState) {
8989

9090
// And finally, for this demo, position the viewer to look at the sightline position
9191
LookAt lookAt = new LookAt().set(pos.latitude, pos.longitude, pos.altitude, WorldWind.ABSOLUTE, 2e4 /*range*/, 0 /*heading*/, 45 /*tilt*/, 0 /*roll*/);
92-
this.getWorldWindow().getCamera().setFromLookAt(this.wwd.getGlobe(), this.wwd.getVerticalExaggeration(), lookAt);
92+
this.getWorldWindow().cameraFromLookAt(lookAt);
9393
}
9494

9595
/**

worldwind-examples/src/main/java/gov/nasa/worldwindx/PlacemarksMilStd2525Activity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
3939
Position pos = new Position(32.4520, 63.44553, 0);
4040
LookAt lookAt = new LookAt().set(pos.latitude, pos.longitude, pos.altitude, WorldWind.ABSOLUTE,
4141
1e5 /*range*/, 0 /*heading*/, 45 /*tilt*/, 0 /*roll*/);
42-
this.getWorldWindow().getCamera().setFromLookAt(this.wwd.getGlobe(), this.wwd.getVerticalExaggeration(), lookAt);
42+
this.getWorldWindow().cameraFromLookAt(lookAt);
4343

4444
// The MIL-STD-2525 rendering library takes time initialize, we'll perform this task via the
4545
// AsyncTask's background thread and then load the symbols in its post execute handler.

worldwind-examples/src/main/java/gov/nasa/worldwindx/PlacemarksSelectDragActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected void onCreate(Bundle savedInstanceState) {
172172

173173
// And finally, for this demo, position the viewer to look at the placemarks
174174
LookAt lookAt = new LookAt().set(34.150, -119.150, 0, WorldWind.ABSOLUTE, 2e4 /*range*/, 0 /*heading*/, 45 /*tilt*/, 0 /*roll*/);
175-
this.getWorldWindow().getCamera().setFromLookAt(this.wwd.getGlobe(), this.wwd.getVerticalExaggeration(), lookAt);
175+
this.getWorldWindow().cameraFromLookAt(lookAt);
176176
}
177177

178178
/**

worldwind-tutorials/src/main/assets/look_at_view_tutorial.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ <h3>LookAtViewFragment.java</h3>
5858
// Apply the new view
5959
LookAt lookAt = new LookAt();
6060
lookAt.set(airport.latitude, airport.longitude, airport.altitude, WorldWind.ABSOLUTE, range, heading, tilt, 0 /*roll*/);
61-
wwd.getCamera().setFromLookAt(wwd.getGlobe(), wwd.getVerticalExaggeration(), lookAt);
61+
wwd.cameraFromLookAt(lookAt);
6262

6363
return wwd;
6464
}

worldwind-tutorials/src/main/assets/navigator_events_tutorial.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,8 @@ <h3>NavigatorEventFragment.java</h3>
8585
// Update the status overlay views whenever the navigator stops moving,
8686
// and also it is moving but at an (arbitrary) maximum refresh rate of 20 Hz.
8787
if (eventAction == WorldWind.NAVIGATOR_STOPPED || elapsedTime > 50) {
88-
// Pick terrain located behind the viewport center point
89-
PickedObject terrainPickedObject = wwd.pick(wwd.getViewport().width / 2f, wwd.getViewport().height / 2f).terrainPickedObject();
90-
Position terrainPosition = terrainPickedObject != null ? terrainPickedObject.getTerrainPosition() : null;
91-
9288
// Get the current camera state to apply to the overlays
93-
event.getCamera().getAsLookAt(wwd.getGlobe(), wwd.getVerticalExaggeration(), terrainPosition, lookAt);
89+
wwd.cameraAsLookAt(lookAt);
9490

9591
// Update the overlays
9692
updateOverlayContents(lookAt, event.getCamera());

worldwind-tutorials/src/main/assets/placemarks_picking_tutorial.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ <h3>PlacemarksPickingFragment.java</h3>
6262

6363
// Position the viewer to look near the airports
6464
LookAt lookAt = new LookAt().set(34.15, -119.15, 0, WorldWind.ABSOLUTE, 2e4 /*range*/, 0 /*heading*/, 45 /*tilt*/, 0 /*roll*/);
65-
wwd.getCamera().setFromLookAt(wwd.getGlobe(), wwd.getVerticalExaggeration(), lookAt);
65+
wwd.cameraFromLookAt(lookAt);
6666

6767
return wwd;
6868
}

worldwind-tutorials/src/main/assets/placemarks_tutorial.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h3>PlacemarksFragment.java</h3>
9090
Position pos = airport.getPosition();
9191
LookAt lookAt = new LookAt().set(pos.latitude, pos.longitude, pos.altitude, WorldWind.ABSOLUTE,
9292
1e5 /*range*/, 0 /*heading*/, 80 /*tilt*/, 0 /*roll*/);
93-
wwd.getCamera().setFromLookAt(wwd.getGlobe(), wwd.getVerticalExaggeration(), lookAt);
93+
wwd.cameraFromLookAt(lookAt);
9494

9595
return wwd;
9696
}

worldwind-tutorials/src/main/java/gov/nasa/worldwindx/LookAtViewFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public WorldWindow createWorldWindow() {
3939
// Apply the new view
4040
LookAt lookAt = new LookAt();
4141
lookAt.set(airport.latitude, airport.longitude, airport.altitude, WorldWind.ABSOLUTE, range, heading, tilt, 0 /*roll*/);
42-
wwd.getCamera().setFromLookAt(wwd.getGlobe(), wwd.getVerticalExaggeration(), lookAt);
42+
wwd.cameraFromLookAt(lookAt);
4343

4444
return wwd;
4545
}

worldwind-tutorials/src/main/java/gov/nasa/worldwindx/NavigatorEventFragment.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,8 @@ public void onNavigatorEvent(WorldWindow wwd, NavigatorEvent event) {
8080
// Update the status overlay views whenever the navigator stops moving,
8181
// and also it is moving but at an (arbitrary) maximum refresh rate of 20 Hz.
8282
if (eventAction == WorldWind.NAVIGATOR_STOPPED || elapsedTime > 50) {
83-
// Pick terrain located behind the viewport center point
84-
PickedObject terrainPickedObject = wwd.pick(wwd.getViewport().width / 2f, wwd.getViewport().height / 2f).terrainPickedObject();
85-
Position terrainPosition = terrainPickedObject != null ? terrainPickedObject.getTerrainPosition() : null;
86-
8783
// Get the current camera state to apply to the overlays
88-
event.getCamera().getAsLookAt(wwd.getGlobe(), wwd.getVerticalExaggeration(), terrainPosition, lookAt);
84+
wwd.cameraAsLookAt(lookAt);
8985

9086
// Update the overlays
9187
updateOverlayContents(lookAt, event.getCamera());

0 commit comments

Comments
 (0)