From 7c0cf9dff9bcba5e85fac60ebe099793fb49f413 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 12 Dec 2005 22:22:28 +0000 Subject: [PATCH] =?UTF-8?q?Mathias=20Fr=C3=B6hlich's=20code,=20Curt=20Olso?= =?UTF-8?q?n's=20comments:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Display the ground intersection point on mouse click (if click not consumed by the gui or the panel.) This should eventually get stuffed into the property tree. --- src/Input/input.cxx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Input/input.cxx b/src/Input/input.cxx index c42938999..fa5552c88 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -57,6 +57,11 @@ #include "input.hxx" +#include +#include
+#include +#include + SG_USING_STD(ifstream); SG_USING_STD(string); SG_USING_STD(vector); @@ -308,6 +313,27 @@ FGInput::doMouseClick (int b, int updown, int x, int y) return; else if (fgHandle3DPanelMouseEvent(b, updown, x, y)) return; + else { + // pui and the panel didn't want the click event so compute a + // terrain intersection point corresponding to the mouse click + // and be happy. This should eventually get written into a set + // of properties so that some other [future] subsystems can do + // something useful with the information. + FGScenery* scenery = globals->get_scenery(); + sgdVec3 start, dir, hit; + if (FGRenderer::getPickInfo(start, dir, x, y) && + scenery->get_cart_ground_intersection(start, dir, hit)) { + + Point3D geod = sgCartToGeod(Point3D(hit[0], hit[1], hit[2])); + + std::cout << "lon = " << geod.lon()*SGD_RADIANS_TO_DEGREES + << " deg, lat = " << geod.lat()*SGD_RADIANS_TO_DEGREES + << " deg, elev = " << geod.elev() + << " m" << std::endl; + } else { + std::cout << "Cannot find intersection point" << std::endl; + } + } } // OK, PUI and the panel didn't want the click