@@ -108,9 +108,8 @@ public Matrix4 computeViewingTransform(Matrix4 result) {
108
108
Logger .logMessage (Logger .ERROR , "Camera" , "computeViewingTransform" , "missingResult" ));
109
109
}
110
110
111
- // TODO interpret altitude mode other than absolute
112
111
// Transform by the local cartesian transform at the camera's position.
113
- this .wwd . getGlobe (). geographicToCartesianTransform (this .position . latitude , this .position . longitude , this . position . altitude , result );
112
+ this .geographicToCartesianTransform (this .position , this .altitudeMode , result );
114
113
115
114
// Transform by the heading, tilt and roll.
116
115
result .multiplyByRotation (0 , 0 , 1 , -this .heading ); // rotate clockwise about the Z axis
@@ -166,6 +165,7 @@ public Camera setFromLookAt(LookAt lookAt) {
166
165
this .modelview .multiplyByMatrix (this .origin );
167
166
168
167
this .position .set (this .originPos );
168
+ this .altitudeMode = WorldWind .ABSOLUTE ; // Calculated position is absolute
169
169
this .heading = this .modelview .extractHeading (lookAt .roll ); // disambiguate heading and roll
170
170
this .tilt = this .modelview .extractTilt ();
171
171
this .roll = lookAt .roll ; // roll passes straight through
@@ -193,9 +193,8 @@ public Camera setFromLookAt(LookAt lookAt) {
193
193
}
194
194
195
195
protected Matrix4 lookAtToViewingTransform (LookAt lookAt , Matrix4 result ) {
196
- // TODO interpret altitude mode other than absolute
197
196
// Transform by the local cartesian transform at the look-at's position.
198
- this .wwd . getGlobe (). geographicToCartesianTransform (lookAt .position . latitude , lookAt .position . longitude , lookAt . position . altitude , result );
197
+ this .geographicToCartesianTransform (lookAt .position , lookAt .altitudeMode , result );
199
198
200
199
// Transform by the heading and tilt.
201
200
result .multiplyByRotation (0 , 0 , 1 , -lookAt .heading ); // rotate clockwise about the Z axis
@@ -211,4 +210,23 @@ protected Matrix4 lookAtToViewingTransform(LookAt lookAt, Matrix4 result) {
211
210
return result ;
212
211
}
213
212
213
+ protected void geographicToCartesianTransform (Position position , @ WorldWind .AltitudeMode int altitudeMode , Matrix4 result ) {
214
+ switch (altitudeMode ) {
215
+ case WorldWind .ABSOLUTE :
216
+ this .wwd .getGlobe ().geographicToCartesianTransform (
217
+ position .latitude , position .longitude , position .altitude * this .wwd .getVerticalExaggeration (), result );
218
+ break ;
219
+ case WorldWind .CLAMP_TO_GROUND :
220
+ this .wwd .getGlobe ().geographicToCartesianTransform (
221
+ position .latitude , position .longitude , this .wwd .getGlobe ().getElevationAtLocation (
222
+ position .latitude , position .longitude ) * this .wwd .getVerticalExaggeration (), result );
223
+ break ;
224
+ case WorldWind .RELATIVE_TO_GROUND :
225
+ this .wwd .getGlobe ().geographicToCartesianTransform (
226
+ position .latitude , position .longitude , (position .altitude + this .wwd .getGlobe ().getElevationAtLocation (
227
+ position .latitude , position .longitude )) * this .wwd .getVerticalExaggeration (), result );
228
+ break ;
229
+ }
230
+ }
231
+
214
232
}
0 commit comments