/** * Converts a screen point to the geographic coordinates on the globe. * * @param screenX X coordinate * @param screenY Y coordinate * @param result Pre-allocated Position receives the geographic coordinates * * @return true if the screen point could be converted; false if the screen point is not on the globe */ public boolean screenPointToGroundPosition(float screenX, float screenY, Position result) { if (this.wwd.rayThroughScreenPoint(screenX, screenY, ray)) { Globe globe = wwd.getGlobe(); if (globe.intersect(ray, this.pickPoint)) { globe.cartesianToGeographic(pickPoint.x, this.pickPoint.y, this.pickPoint.z, result); return true; } } return false; }
/** * Converts a screen point to the geographic coordinates on the globe. * * @param screenX X coordinate * @param screenY Y coordinate * @param result Pre-allocated Position receives the geographic coordinates * * @return true if the screen point could be converted; false if the screen point is not on the globe */ public boolean screenPointToGroundPosition(float screenX, float screenY, Position result) { if (this.wwd.rayThroughScreenPoint(screenX, screenY, ray)) { Globe globe = wwd.getGlobe(); if (globe.intersect(ray, this.pickPoint)) { globe.cartesianToGeographic(pickPoint.x, this.pickPoint.y, this.pickPoint.z, result); return true; } } return false; } }
protected LookAt cameraToLookAt(Globe globe, Camera camera, LookAt result) { this.cameraToViewingMatrix(globe, camera, this.modelview); this.modelview.extractEyePoint(this.forwardRay.origin); this.modelview.extractForwardVector(this.forwardRay.direction); if (!globe.intersect(this.forwardRay, this.originPoint)) { double horizon = globe.horizonDistance(camera.altitude); this.forwardRay.pointAt(horizon, this.originPoint); } globe.cartesianToGeographic(this.originPoint.x, this.originPoint.y, this.originPoint.z, this.originPos); globe.cartesianToLocalTransform(this.originPoint.x, this.originPoint.y, this.originPoint.z, this.origin); this.modelview.multiplyByMatrix(this.origin); result.latitude = this.originPos.latitude; result.longitude = this.originPos.longitude; result.altitude = this.originPos.altitude; result.range = -this.modelview.m[11]; result.heading = this.modelview.extractHeading(camera.roll); // disambiguate heading and roll result.tilt = this.modelview.extractTilt(); result.roll = camera.roll; // roll passes straight through return result; }