{
// Find the closest points between the rays through each screen point, and the ray from the control point
// and in the direction of the globe's surface normal. Compute the elevation difference between these two
// points, and use that as the change in polygon height.
Position referencePos = this._pol_.getReferencePosition();
if (referencePos == null)
return;
Vec4 referencePoint = super._wwd.getModel().getGlobe().computePointFromPosition(referencePos);
Vec4 surfaceNormal = super._wwd.getModel().getGlobe().computeSurfaceNormalAtLocation(referencePos.getLatitude(),
referencePos.getLongitude());
Line verticalRay = new Line(referencePoint, surfaceNormal);
Line screenRay = super._wwd.getView().computeRayFromScreenPoint(mousePoint.getX(), mousePoint.getY());
Line previousScreenRay = super._wwd.getView().computeRayFromScreenPoint(previousMousePoint.getX(),
previousMousePoint.getY());
Vec4 pointOnLine = AirspaceEditorUtil.nearestPointOnLine(verticalRay, screenRay);
Vec4 previousPointOnLine = AirspaceEditorUtil.nearestPointOnLine(verticalRay, previousScreenRay);
Position pos = super._wwd.getModel().getGlobe().computePositionFromPoint(pointOnLine);
Position previousPos = super._wwd.getModel().getGlobe().computePositionFromPoint(previousPointOnLine);
double elevationChange = pos.getElevation() - previousPos.getElevation();
java.util.List<Position> boundary = new ArrayList<Position>();
for (LatLon ll : ((ExtrudedPolygon) super._pol_).getOuterBoundary())
{
boundary.add(new Position(ll, ((Position) ll).getElevation() + elevationChange));
}
((ExtrudedPolygon) super._pol_).setOuterBoundary(boundary);
}