void DrawWayPoint(WayPoint wp, Color c, string label = null, float r = IconSize, Texture2D texture = null) { if (DrawGroundMarker(vessel.mainBody, wp, c, r, texture)) { DrawLabelAtPointer(label ?? wp.SurfaceDescription(vessel), wp.DistanceTo(vessel)); } }
public bool DrawWayPoint(WayPoint wp, Color c, string label = null, float size = Markers.DefaultIconSize) { Vector3d worldPos; if (Markers.DrawCBMarker(vessel.mainBody, wp.Pos, c, out worldPos, WayPointMarker, size)) { DrawLabelAtPointer(label ?? wp.FullInfo(vessel), wp.DistanceTo(vessel)); select_waypoint(wp); return(true); } return(false); }
public void WaypointOverlay() { if (TCA == null || !TCA.Available || !TCAGui.HUD_enabled) { return; } if (SelectingTarget) { var coords = MapView.MapIsEnabled? Coordinates.GetAtPointer(vessel.mainBody) : Coordinates.GetAtPointerInFlight(); if (coords != null) { var t = new WayPoint(coords); DrawGroundMarker(vessel.mainBody, coords, new Color(1.0f, 0.56f, 0.0f)); DrawLabelAtPointer(coords.FullDescription(vessel), t.DistanceTo(vessel)); if (!clicked) { if (Input.GetMouseButtonDown(0)) { clicked = true; } else if (Input.GetMouseButtonDown(1)) { clicked_time = DateTime.Now; clicked = true; } } else { if (Input.GetMouseButtonUp(0)) { if (select_single) { SelectingTarget = false; select_single = false; VSL.SetTarget(t); MapView.ExitMapView(); } else { AddTargetDamper.Run(() => CFG.Waypoints.Enqueue(t)); } CFG.ShowWaypoints = true; clicked = false; } if (Input.GetMouseButtonUp(1)) { SelectingTarget &= (DateTime.Now - clicked_time).TotalSeconds >= GLB.ClickDuration; clicked = false; } } } } bool current_target_drawn = false; if (CFG.ShowWaypoints) { var i = 0; var num = (float)(CFG.Waypoints.Count - 1); WayPoint wp0 = null; foreach (var wp in CFG.Waypoints) { current_target_drawn |= wp.Equals(CFG.Target); wp.UpdateCoordinates(vessel.mainBody); var c = marker_color(i, num); if (wp0 == null) { DrawPath(vessel, wp, c); } else { DrawPath(vessel.mainBody, wp0, wp, c); } if (DrawGroundMarker(vessel.mainBody, wp, c)) { DrawLabelAtPointer(wp.SurfaceDescription(vessel), wp.DistanceTo(vessel)); } wp0 = wp; i++; } } //current target and anchor if (CFG.Anchor != null) { DrawWayPoint(CFG.Anchor, Color.cyan, "Anchor"); current_target_drawn |= CFG.Anchor.Equals(CFG.Target); } if (CFG.Target != null && !current_target_drawn && (!CFG.Target.IsVessel || CFG.Target.GetVessel().LandedOrSplashed)) { DrawWayPoint(CFG.Target, Color.magenta, "Target"); } //custom markers VSL.Info.CustomMarkersWP.ForEach(m => DrawWayPoint(m, Color.red, m.Name)); VSL.Info.CustomMarkersVec.ForEach(m => DrawWorldMarker(m, Color.red, "Custom WayPoint")); #if DEBUG // VSL.Engines.All.ForEach(e => e.engine.thrustTransforms.ForEach(t => DrawWorldMarker(t.position, Color.red, e.name))); // DrawWorldMarker(VSL.vessel.transform.position, Color.yellow, "Vessel"); // DrawWorldMarker(VSL.Physics.wCoM, Color.green, "CoM"); #endif }
public void WaypointOverlay() { if (PN == null || TCA == null || !TCA.Available || !GUIWindowBase.HUD_enabled) { return; } if (SelectingTarget) { var coords = MapView.MapIsEnabled? Coordinates.GetAtPointer(vessel.mainBody) : Coordinates.GetAtPointerInFlight(); if (coords != null) { var t = new WayPoint(coords); Markers.DrawCBMarker(vessel.mainBody, coords, new Color(1.0f, 0.56f, 0.0f), WayPointMarker); DrawLabelAtPointer(coords.FullDescription(vessel), t.DistanceTo(vessel)); if (!clicked) { if (Input.GetMouseButtonDown(0)) { clicked = true; } else if (Input.GetMouseButtonDown(1)) { clicked_time = DateTime.Now; clicked = true; } } else { if (Input.GetMouseButtonUp(0)) { t.Update(VSL); t.Movable = true; if (select_single) { t.Name = "Target"; SelectingTarget = false; select_single = false; VSL.SetTarget(null, t); if (!was_in_map_view) { MapView.ExitMapView(); } } else { t.Name = "Waypoint " + (CFG.Path.Count + 1); AddTargetDamper.Run(() => CFG.Path.Enqueue(t)); } CFG.ShowPath = true; clicked = false; } if (Input.GetMouseButtonUp(1)) { SelectingTarget &= (DateTime.Now - clicked_time).TotalSeconds >= GLB.ClickDuration; clicked = false; } } } } bool current_target_drawn = false; var camera = Markers.CurrentCamera; if (CFG.ShowPath) { var i = 0; var num = (float)(CFG.Path.Count - 1); WayPoint wp0 = null; var total_dist = 0f; var dist2cameraF = Mathf.Pow(Mathf.Max((camera.transform.position - VSL.vessel.transform.position).magnitude, 1), GLB.CameraFadeinPower); foreach (var wp in CFG.Path) { current_target_drawn |= wp.Equals(CFG.Target); wp.UpdateCoordinates(vessel.mainBody); var dist = -1f; if (wp0 != null && wp != selected_waypoint) { total_dist += (float)wp.DistanceTo(wp0, VSL.Body) / dist2cameraF; dist = total_dist; } var r = Markers.DefaultIconSize; var c = marker_color(i, num, dist); if (wp0 == null) { DrawPath(vessel, wp, c); } else { DrawPath(vessel.mainBody, wp0, wp, c); } if (wp == edited_waypoint) { c = edited_color; r = Markers.DefaultIconSize * 2; } else if (wp.Land) { r = Markers.DefaultIconSize * 2; } if (DrawWayPoint(wp, c, size:r)) { DrawLabelAtPointer(wp.FullInfo(vessel), wp.DistanceTo(vessel)); select_waypoint(wp); } else if (wp == selected_waypoint) { DrawLabelAtPointer(wp.FullInfo(vessel), wp.DistanceTo(vessel)); } wp0 = wp; i++; } } //current target and anchor if (CFG.Anchor != null) { DrawWayPoint(CFG.Anchor, Color.cyan, "Anchor"); current_target_drawn |= CFG.Anchor.Equals(CFG.Target); } if (CFG.Target && !current_target_drawn && (!CFG.Target.IsVessel || CFG.Target.GetVessel().LandedOrSplashed)) { DrawWayPoint(CFG.Target, Color.magenta, "Target"); } //custom markers VSL.Info.CustomMarkersWP.ForEach(m => DrawWayPoint(m, Color.red, m.Name)); VSL.Info.CustomMarkersVec.ForEach(m => Markers.DrawWorldMarker(m, Color.red, "Custom WayPoint", WayPointMarker)); //modify the selected waypoint if (!SelectingTarget && selected_waypoint != null) { if (changing_altitude) { var dist2camera = (selected_waypoint.GetTransform().position - camera.transform.position).magnitude; var dy = (Input.mousePosition.y - last_mouse_y) / Screen.height * dist2camera * Math.Tan(camera.fieldOfView * Mathf.Deg2Rad) * 2; last_mouse_y = Input.mousePosition.y; selected_waypoint.Pos.Alt += dy; selected_waypoint.Update(VSL); } else { var coords = MapView.MapIsEnabled? Coordinates.GetAtPointer(vessel.mainBody) : Coordinates.GetAtPointerInFlight(); if (coords != null) { selected_waypoint.Pos = coords; selected_waypoint.Update(VSL); } } if (Input.GetMouseButtonUp(0) || (changing_altitude && Input.GetMouseButtonUp(2))) { if (changing_altitude) { selected_waypoint.Pos.Alt = Math.Max(selected_waypoint.Pos.Alt, selected_waypoint.Pos.SurfaceAlt(vessel.mainBody)); } selected_waypoint = null; orig_coordinates = null; changing_altitude = false; } else if (Input.GetMouseButtonDown(1)) { selected_waypoint.Pos = orig_coordinates; selected_waypoint.Update(VSL); selected_waypoint = null; orig_coordinates = null; changing_altitude = false; } } #if DEBUG // VSL.Engines.All.ForEach(e => e.engine.thrustTransforms.ForEach(t => DrawWorldMarker(t.position, Color.red, e.name))); // DrawWorldMarker(VSL.vessel.transform.position, Color.yellow, "Vessel"); // DrawWorldMarker(VSL.Physics.wCoM, Color.green, "CoM"); #endif }