public PointLatLngAlt getMousePos(int x, int y) { //https://gamedev.stackexchange.com/questions/103483/opentk-ray-picking int[] viewport = new int[4]; Matrix4 modelMatrix, projMatrix; MakeCurrent(); GL.GetFloat(GetPName.ModelviewMatrix, out modelMatrix); GL.GetFloat(GetPName.ProjectionMatrix, out projMatrix); GL.GetInteger(GetPName.Viewport, viewport); var _start = UnProject(new Vector3(x, y, 0.0f), projMatrix, modelMatrix, new Size(viewport[2], viewport[3])); var _end = UnProject(new Vector3(x, y, 1), projMatrix, modelMatrix, new Size(viewport[2], viewport[3])); var pos = new utmpos(utmcenter[0] + _end.X, utmcenter[1] + _end.Y, utmzone); var plla = pos.ToLLA(); plla.Alt = _end.Z; var point = srtm.getIntersectionWithTerrain(center, plla); return(point); }
/// <summary> /// this is a debug function /// </summary> /// <param name="pos"></param> /// <param name="tag"></param> static void addtomap(utmpos pos, string tag) { if (tag == "M") { return; } polygons.Markers.Add(new GMapMarkerWP(pos.ToLLA(), tag)); }
/// <summary> /// this is a debug function /// </summary> /// <param name="pos"></param> /// <param name="tag"></param> static void addtomap(utmpos pos, string tag) { if (tag == "M") { return; } polygons.Markers.Add(new GMapMarkerWP(pos.ToLLA(), tag)); map.ZoomAndCenterMarkers("polygons"); map.Invalidate(); }
/// <summary> /// this is a debug function /// </summary> /// <param name="pos"></param> /// <param name="tag"></param> static void Addtomap(utmpos pos, string tag) { polygons.Markers.Add(new GMapMarkerWP(pos.ToLLA(), tag)); }