diff --git a/Plane.FormationCreator/Formation/CopterManager.cs b/Plane.FormationCreator/Formation/CopterManager.cs index d6be8cb..921b8b2 100644 --- a/Plane.FormationCreator/Formation/CopterManager.cs +++ b/Plane.FormationCreator/Formation/CopterManager.cs @@ -104,6 +104,14 @@ namespace Plane.FormationCreator.Formation public List ShowCopter = new List(); + //3维视图显示比例,有些大的图案显示不出来可以缩小 + private float _scale3d = 1.0f; + public float scale3d + { + get { return _scale3d; } + set { Set(nameof(scale3d), ref _scale3d, value); } + } + public CopterCollection Copters { get;} = new CopterCollection(); diff --git a/Plane.FormationCreator/ViewModels/ConfigVirtualIdViewModel.cs b/Plane.FormationCreator/ViewModels/ConfigVirtualIdViewModel.cs index 3ff025d..d1210f0 100644 --- a/Plane.FormationCreator/ViewModels/ConfigVirtualIdViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ConfigVirtualIdViewModel.cs @@ -95,7 +95,7 @@ namespace Plane.FormationCreator.ViewModels FlightTaskManager _flightTaskManager = ServiceLocator.Current.GetInstance(); float StepDis_Row = _flightTaskManager.ColumnDistance; //行内间距-列间距 float StepDis_Col = _flightTaskManager.RowDistance ; //列间距-行间距 - float FindDis =Math.Min(StepDis_Row, StepDis_Col); //查找半径 + float FindDis =Math.Min(StepDis_Row, StepDis_Col)*0.8f; //查找半径 if (_copterManager.AcceptingControlCopters.Count() >= 2) { var copters = _copterManager.AcceptingControlCopters.ToList(); diff --git a/Plane.FormationCreator/ViewModels/ConnectViewModel.cs b/Plane.FormationCreator/ViewModels/ConnectViewModel.cs index 88b7b51..41b1e88 100644 --- a/Plane.FormationCreator/ViewModels/ConnectViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ConnectViewModel.cs @@ -125,7 +125,16 @@ namespace Plane.FormationCreator.ViewModels set { Set(nameof(CopterNum), ref _CopterNum, value); } } + + + public float scale3d + { + get { return _copterManager.scale3d ; } + set { _copterManager.scale3d = value;} + } + + private int _CopterSum=100; public int CopterSum { diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs index bdf5377..ed17211 100644 --- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs @@ -1155,7 +1155,8 @@ namespace Plane.FormationCreator.ViewModels //循环3次 发送起飞命令 避免通信问题 for (int i = 0; i < 10; i++) { - await _commModuleManager.DoMissionStartAsync(utchour, + await _commModuleManager.DoMissionStartAsync(_copterManager.Copters, + utchour, utcminute, utcsecond, _flightTaskManager.OriginLng, @@ -1384,7 +1385,7 @@ namespace Plane.FormationCreator.ViewModels } } var targetCopter = _copterManager.Copters.FirstOrDefault(o => o.VirtualId == (i+1)); - bool result = await _commModuleManager.WriteMissionListAsync(short.Parse(targetCopter.Id), missions); + bool result = await _commModuleManager.WriteMissionListAsync(targetCopter, missions); //CommWriteMissinState state = new CommWriteMissinState(result); //_commModuleManager.missionWriteState.Add(int.Parse(_copterManager.Copters[i].Id), state); if (!result) diff --git a/Plane.FormationCreator/ViewModels/View3DViewModel.cs b/Plane.FormationCreator/ViewModels/View3DViewModel.cs index e6f88a5..3d0ac8a 100644 --- a/Plane.FormationCreator/ViewModels/View3DViewModel.cs +++ b/Plane.FormationCreator/ViewModels/View3DViewModel.cs @@ -24,7 +24,7 @@ namespace Plane.FormationCreator.ViewModels { private FlightTaskManager _flightTaskManager; private CopterManager _copterManager; - + private View3DManager _view3DManager = ServiceLocator.Current.GetInstance(); public View3DViewModel(FlightTaskManager flightTaskManager, CopterManager copterManager) @@ -144,7 +144,7 @@ namespace Plane.FormationCreator.ViewModels //meshBuilderwaypoint.AddTriangle(new Point3D(-0.1, -0.1, 0), new Point3D(0.1, -0.1, 0), new Point3D(0, 0.2, 0)); //飞机点的大小形状 - meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3); + meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3* _copterManager.scale3d); var meshwaypoint = meshBuilderwaypoint.ToMesh(true); double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2; @@ -153,12 +153,17 @@ namespace Plane.FormationCreator.ViewModels double x = GeographyUtils.CalcDistance(observationLatLng.Item2, 0, 0, copter.Longitude, 0, 0) / 2; if (observationLatLng.Item2 > copter.Longitude) x = -x; + double z = copter.Altitude + 0.1; + + x *= _copterManager.scale3d; + y *= _copterManager.scale3d; + z *= _copterManager.scale3d; var model3D = new GeometryModel3D { Geometry = meshwaypoint, - Transform = new TranslateTransform3D(x, y, copter.Altitude + 0.1), + Transform = new TranslateTransform3D(x, y, z), Material = MaterialHelper.CreateMaterial(Color.FromRgb(238, 210, 238)), BackMaterial = MaterialHelper.CreateMaterial(Color.FromRgb(238, 210, 238)) }; @@ -181,7 +186,9 @@ namespace Plane.FormationCreator.ViewModels double z = Math.Round(copter.Altitude / 2, 2); GeometryModel3D panle3D = planeModel3Ds[copter]; - + x *= _copterManager.scale3d; + y *= _copterManager.scale3d; + z *= _copterManager.scale3d; if (x != panle3D.Transform.Value.OffsetX || y != panle3D.Transform.Value.OffsetY || z != panle3D.Transform.Value.OffsetZ) { panle3D.Transform = new TranslateTransform3D(x, y, z); @@ -208,7 +215,7 @@ namespace Plane.FormationCreator.ViewModels private void SelectTask() - { + { if (waypointGroup == null) waypointGroup = new Model3DGroup(); waypointGroup.Children.Clear(); if (_flightTaskManager.SelectedTaskIndex > 0) @@ -227,7 +234,8 @@ namespace Plane.FormationCreator.ViewModels //modelGroup.Children.Clear(); var meshBuilderwaypoint = new MeshBuilder(false, false); - meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.2); + //航点的大小形状 + meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.2* _copterManager.scale3d); var meshwaypoint = meshBuilderwaypoint.ToMesh(true); var greenMaterial = MaterialHelper.CreateMaterial(Color.FromRgb(0,255,0)); @@ -239,12 +247,16 @@ namespace Plane.FormationCreator.ViewModels double x = GeographyUtils.CalcDistance(observationLatLng.Item2, 0, 0, info.TargetLng, 0, 0)/2; if (observationLatLng.Item2 > info.TargetLng) x = -x; + double z = info.TargetAlt / 2; + x *= _copterManager.scale3d; + y *= _copterManager.scale3d; + z *= _copterManager.scale3d; waypointGroup.Children.Add(new GeometryModel3D { Geometry = meshwaypoint, - Transform = new TranslateTransform3D(x, y, info.TargetAlt/2), + Transform = new TranslateTransform3D(x, y, z), Material = greenMaterial, BackMaterial = greenMaterial }); diff --git a/Plane.FormationCreator/Views/ConnectWindow.xaml b/Plane.FormationCreator/Views/ConnectWindow.xaml index 517afae..943972f 100644 --- a/Plane.FormationCreator/Views/ConnectWindow.xaml +++ b/Plane.FormationCreator/Views/ConnectWindow.xaml @@ -23,6 +23,9 @@ + + + @@ -35,23 +38,11 @@ - - - + + + + + + + + +