1增加观测者位置图标,修改后直接可以使用
2增加配置FC_VER_NO = 3 使用小航点同时达到模式计算模拟飞行 3增加灯光框架,可实现闪烁等,但实际使用太慢,暂时不用
This commit is contained in:
parent
b729f6b78e
commit
c2d26dd62c
@ -631,7 +631,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
if ((username== supername) && (password== superpass) &&(DateTime.UtcNow < CopterCollection.Expire_SuperUser) )
|
if ((username== supername) && (password== superpass) &&(DateTime.UtcNow < CopterCollection.Expire_SuperUser) )
|
||||||
{
|
{
|
||||||
// NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN);
|
// NetLogined(supername, superDispname, -1, -1, LEVEL_ADMIN);
|
||||||
NetLogined(supername, superDispname,6, 50, LEVEL_NORMAL);
|
NetLogined(supername, superDispname,6, 300, LEVEL_NORMAL);
|
||||||
VersionControl.SaveLogininfoToIni(supername, superpass, savepassword); //超级密码是否保存---不要就不保存
|
VersionControl.SaveLogininfoToIni(supername, superpass, savepassword); //超级密码是否保存---不要就不保存
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
public static double DistanceTo(this ICopter copter, ICopter copter2)
|
public static double DistanceTo(this ICopter copter, ICopter copter2)
|
||||||
{
|
{
|
||||||
return GeographyUtils.CalcDistance(copter.Latitude, copter.Longitude, copter.Altitude, copter2.Latitude, copter2.Longitude, copter2.Altitude);
|
return GeographyUtils.CalcDistance(copter.Latitude, copter.Longitude, copter.Altitude, copter2.Latitude, copter2.Longitude, copter2.Altitude);
|
||||||
|
//return GeographyUtils.CalcDistance_simple(copter.Latitude, copter.Longitude, copter.Altitude, copter2.Latitude, copter2.Longitude, copter2.Altitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double InPlaneDistanceTo(this ICopter copter, double targetLat, double targetLng)
|
public static double InPlaneDistanceTo(this ICopter copter, double targetLat, double targetLng)
|
||||||
|
@ -541,6 +541,24 @@ namespace Plane.FormationCreator.Formation
|
|||||||
set { Set(nameof(OriginLng), ref _OriginLng, value); }
|
set { Set(nameof(OriginLng), ref _OriginLng, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double _ObserverLat = 0;
|
||||||
|
public double ObserverLat
|
||||||
|
{
|
||||||
|
get { return _ObserverLat; }
|
||||||
|
set { Set(nameof(ObserverLat), ref _ObserverLat, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _ObserverLng = 0;
|
||||||
|
public double ObserverLng
|
||||||
|
{
|
||||||
|
get { return _ObserverLng; }
|
||||||
|
set { Set(nameof(ObserverLng), ref _ObserverLng, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 起始点作为参考,设置起始点后飞行写入的数据将为相对坐标
|
/// 起始点作为参考,设置起始点后飞行写入的数据将为相对坐标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -767,6 +785,8 @@ namespace Plane.FormationCreator.Formation
|
|||||||
altitude: 0 );
|
altitude: 0 );
|
||||||
//设置灯光为默认颜色
|
//设置灯光为默认颜色
|
||||||
fc.LEDColor = CopterManager.CopterDefaultColor;// "000000";
|
fc.LEDColor = CopterManager.CopterDefaultColor;// "000000";
|
||||||
|
fc.LEDMode = 0;
|
||||||
|
fc.LEDInterval = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2626,6 +2646,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
Message.Show($"{DateTime.Now.ToString("HH:mm:ss")}:任务开始");
|
Message.Show($"{DateTime.Now.ToString("HH:mm:ss")}:任务开始");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
//设置模拟飞行更新间隔,都是I7配置下
|
//设置模拟飞行更新间隔,都是I7配置下
|
||||||
int update_int = 50; //300以内50流畅
|
int update_int = 50; //300以内50流畅
|
||||||
if ((_copterManager.Copters.Count() > 300) && ((_copterManager.Copters.Count() <= 500)))
|
if ((_copterManager.Copters.Count() > 300) && ((_copterManager.Copters.Count() <= 500)))
|
||||||
@ -2634,7 +2655,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
update_int = 150; //极限了 500-1000可以用
|
update_int = 150; //极限了 500-1000可以用
|
||||||
foreach (var copter in _copterManager.Copters)
|
foreach (var copter in _copterManager.Copters)
|
||||||
copter.sim_update_int = update_int;
|
copter.sim_update_int = update_int;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
await RunAsync();
|
await RunAsync();
|
||||||
|
@ -115,7 +115,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int RuningTaskRemaining = 0;
|
// private int RuningTaskRemaining = 0;
|
||||||
|
|
||||||
private async Task FlyToTaskFlySingleCopterAsync(FlightTaskSingleCopterInfo info)
|
private async Task FlyToTaskFlySingleCopterAsync(FlightTaskSingleCopterInfo info)
|
||||||
{
|
{
|
||||||
@ -162,14 +162,15 @@ namespace Plane.FormationCreator.Formation
|
|||||||
}
|
}
|
||||||
//发送目标航点1次
|
//发送目标航点1次
|
||||||
|
|
||||||
await info.Copter.FlyToAsync(targetLat, targetLng, info.TargetAlt);
|
await info.Copter.FlyToAsync(targetLat, targetLng, info.TargetAlt, task.FlytoTime);
|
||||||
// await Task.Delay(10).ConfigureAwait(false);
|
// await Task.Delay(10).ConfigureAwait(false);
|
||||||
|
|
||||||
dtNow = DateTime.Now;
|
dtNow = DateTime.Now;
|
||||||
ts = dtNow - dtLastTime;
|
ts = dtNow - dtLastTime;
|
||||||
|
|
||||||
int sendFlyToTimes = 0;
|
// int sendFlyToTimes = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
//第0个任务为takeoff
|
//第0个任务为takeoff
|
||||||
if (taskIndex > 0)
|
if (taskIndex > 0)
|
||||||
{
|
{
|
||||||
@ -177,6 +178,7 @@ namespace Plane.FormationCreator.Formation
|
|||||||
if (prevTask.TaskType == FlightTaskType.FlyTo && prevTask.LoiterTime == 0)
|
if (prevTask.TaskType == FlightTaskType.FlyTo && prevTask.LoiterTime == 0)
|
||||||
flyToTime += prevTask.RuningTaskRemaining;
|
flyToTime += prevTask.RuningTaskRemaining;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
//while (!info.Copter.ArrivedTarget(info.TargetLat, info.TargetLng, info.TargetAlt)) //按航点飞 :所有Copter到达目标点开始飞下个航点
|
//while (!info.Copter.ArrivedTarget(info.TargetLat, info.TargetLng, info.TargetAlt)) //按航点飞 :所有Copter到达目标点开始飞下个航点
|
||||||
while (ts.TotalMilliseconds < (flyToTime + loiterTime)) //按时间轴飞:当前任务时间到达后自动飞往下个航点
|
while (ts.TotalMilliseconds < (flyToTime + loiterTime)) //按时间轴飞:当前任务时间到达后自动飞往下个航点
|
||||||
|
@ -105,30 +105,20 @@ namespace Plane.FormationCreator.Formation
|
|||||||
|
|
||||||
//虚拟飞机5秒后不起飞会自动上锁
|
//虚拟飞机5秒后不起飞会自动上锁
|
||||||
await copter.UnlockAsync();
|
await copter.UnlockAsync();
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) // added by ZJF
|
|
||||||
{
|
|
||||||
await copter.TakeOffAsync();
|
await copter.TakeOffAsync();
|
||||||
await Task.Delay(50).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var copterNextTask = _flightTaskManager.Tasks[TaskIndex + 1].SingleCopterInfos[copterIndex];
|
var copterNextTask = _flightTaskManager.Tasks[TaskIndex + 1].SingleCopterInfos[copterIndex];
|
||||||
float takeOffAlt = copterNextTask.TargetAlt;
|
float takeOffAlt = copterNextTask.TargetAlt;
|
||||||
|
|
||||||
info.TargetLat = info.Copter.Latitude;
|
info.TargetLat = info.Copter.Latitude;
|
||||||
info.TargetLng = info.Copter.Longitude;
|
info.TargetLng = info.Copter.Longitude;
|
||||||
|
FlightTask task = _flightTaskManager.CurrentRunningTask;
|
||||||
// for (int j = 0; j < 3; j++)
|
//开始往上飞
|
||||||
// {
|
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt, task.TakeOffTime- info.TakeOffWaitTime); //秒
|
||||||
await info.Copter.FlyToAsync(info.TargetLat, info.TargetLng, takeOffAlt);
|
|
||||||
// await Task.Delay(10).ConfigureAwait(false);
|
|
||||||
// }
|
|
||||||
//解锁起飞用暗紫色
|
//解锁起飞用暗紫色
|
||||||
info.Copter.LEDColor = CopterManager.CopterTakeoffColor;
|
info.Copter.LEDColor = CopterManager.CopterTakeoffColor;
|
||||||
|
|
||||||
dtNow = DateTime.Now;
|
dtNow = DateTime.Now;
|
||||||
ts = dtNow - dtLastTime;
|
ts = dtNow - dtLastTime;
|
||||||
FlightTask task = _flightTaskManager.CurrentRunningTask;
|
|
||||||
|
|
||||||
while (ts.TotalMilliseconds < task.TakeOffTime * 1000)
|
while (ts.TotalMilliseconds < task.TakeOffTime * 1000)
|
||||||
{
|
{
|
||||||
|
@ -371,6 +371,9 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
id: id,
|
id: id,
|
||||||
name: id
|
name: id
|
||||||
);
|
);
|
||||||
|
if (_copterManager.FC_VER_NO >= 3)
|
||||||
|
copter.FlightControlMode = 1;
|
||||||
|
else copter.FlightControlMode = 0;
|
||||||
//不再预先分配VID
|
//不再预先分配VID
|
||||||
// copter.VirtualId = _virtualCopterId;
|
// copter.VirtualId = _virtualCopterId;
|
||||||
await copter.ConnectAsync();
|
await copter.ConnectAsync();
|
||||||
@ -473,6 +476,8 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
_lastVirtualCopterLocation = null;
|
_lastVirtualCopterLocation = null;
|
||||||
_flightTaskManager.OriginLat = 0;
|
_flightTaskManager.OriginLat = 0;
|
||||||
_flightTaskManager.OriginLng = 0;
|
_flightTaskManager.OriginLng = 0;
|
||||||
|
_flightTaskManager.ObserverLat = 0;
|
||||||
|
_flightTaskManager.ObserverLng = 0;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,6 +317,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
MapMode = 1;
|
MapMode = 1;
|
||||||
b2DMapMode = false;
|
b2DMapMode = false;
|
||||||
_flightTaskManager.TaskRun_2D = b2DMapMode; //3D模式模拟显示
|
_flightTaskManager.TaskRun_2D = b2DMapMode; //3D模式模拟显示
|
||||||
|
mainw.map3D.ResetCamera();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
planeModel3Ds.Clear();
|
planeModel3Ds.Clear();
|
||||||
planeGroup.Children.Clear();
|
planeGroup.Children.Clear();
|
||||||
observationLatLng = null;
|
observationLatLng = null;
|
||||||
|
SelectTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Copter_LocationChanged(object sender, EventArgs e)
|
private void Copter_LocationChanged(object sender, EventArgs e)
|
||||||
@ -109,20 +110,18 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<ICopter, GeometryModel3D> planeModel3Ds = new Dictionary<ICopter, GeometryModel3D>();
|
private Dictionary<ICopter, GeometryModel3D> planeModel3Ds = new Dictionary<ICopter, GeometryModel3D>();
|
||||||
Tuple<double, double> observationLatLng = null;
|
private Tuple<double, double> observationLatLng = null;
|
||||||
|
|
||||||
private void AddOrMove3DCopter(ICopter copter)
|
//得到观测位置
|
||||||
|
//observationLatLng 观察点坐标,第一列的中间再往前2个中间距离)
|
||||||
|
//观测点的位置放到最后排飞机的中间位置
|
||||||
|
private void getobservationpos()
|
||||||
{
|
{
|
||||||
if (_flightTaskManager.TaskRun_2D) return; //不在3D模式运行直接退出
|
observationLatLng = new Tuple<double, double>(_flightTaskManager.ObserverLat, _flightTaskManager.ObserverLng);
|
||||||
//var copternum1 = _copterManager.Copters.FirstOrDefault();
|
/*
|
||||||
if (_flightTaskManager.OriginLat == 0 || _flightTaskManager.OriginLng == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
//第一列到中间的距离
|
//第一列到中间的距离
|
||||||
float midColDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
|
float midColDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
|
||||||
|
|
||||||
if (observationLatLng == null)
|
|
||||||
{
|
|
||||||
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||||
_flightTaskManager.OriginLat,
|
_flightTaskManager.OriginLat,
|
||||||
_flightTaskManager.OriginLng,
|
_flightTaskManager.OriginLng,
|
||||||
@ -132,14 +131,27 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
observationLatLng.Item1,
|
observationLatLng.Item1,
|
||||||
observationLatLng.Item2,
|
observationLatLng.Item2,
|
||||||
_flightTaskManager.Orientation + 180,
|
_flightTaskManager.Orientation + 180,
|
||||||
midColDistance * 2);
|
midColDistance * 4);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void AddOrMove3DCopter(ICopter copter)
|
||||||
|
{
|
||||||
|
if (_flightTaskManager.TaskRun_2D) return; //不在3D模式运行直接退出
|
||||||
|
//var copternum1 = _copterManager.Copters.FirstOrDefault();
|
||||||
|
if (_flightTaskManager.OriginLat == 0 || _flightTaskManager.OriginLng == 0)
|
||||||
|
return;
|
||||||
|
//得到观测位置
|
||||||
|
if (observationLatLng == null)
|
||||||
|
{
|
||||||
|
getobservationpos();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//没有这架飞机就加入
|
//没有这架飞机就加入
|
||||||
if (!planeModel3Ds.ContainsKey(copter))
|
if (!planeModel3Ds.ContainsKey(copter))
|
||||||
{
|
{
|
||||||
|
|
||||||
//观测点的位置放到最后排飞机的中间位置
|
|
||||||
|
|
||||||
var meshBuilderwaypoint = new MeshBuilder(false, false);
|
var meshBuilderwaypoint = new MeshBuilder(false, false);
|
||||||
|
|
||||||
//meshBuilderwaypoint.AddTriangle(new Point3D(-0.1, -0.1, 0), new Point3D(0.1, -0.1, 0), new Point3D(0, 0.2, 0));
|
//meshBuilderwaypoint.AddTriangle(new Point3D(-0.1, -0.1, 0), new Point3D(0.1, -0.1, 0), new Point3D(0, 0.2, 0));
|
||||||
@ -147,12 +159,13 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3* _copterManager.scale3d);
|
meshBuilderwaypoint.AddSphere(new Point3D(0, 0, 0), 0.3* _copterManager.scale3d);
|
||||||
var meshwaypoint = meshBuilderwaypoint.ToMesh(true);
|
var meshwaypoint = meshBuilderwaypoint.ToMesh(true);
|
||||||
|
|
||||||
|
//离观测点距离y
|
||||||
double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2;
|
double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2;
|
||||||
if (observationLatLng.Item1 > copter.Latitude) y = -y;
|
if (observationLatLng.Item1 > copter.Latitude) y = -y;
|
||||||
|
//离观测点距离x
|
||||||
double x = GeographyUtils.CalcDistance(observationLatLng.Item2, 0, 0, copter.Longitude, 0, 0) / 2;
|
double x = GeographyUtils.CalcDistance(observationLatLng.Item2, 0, 0, copter.Longitude, 0, 0) / 2;
|
||||||
if (observationLatLng.Item2 > copter.Longitude) x = -x;
|
if (observationLatLng.Item2 > copter.Longitude) x = -x;
|
||||||
|
//离观测点距离z
|
||||||
double z = copter.Altitude + 0.1;
|
double z = copter.Altitude + 0.1;
|
||||||
|
|
||||||
x *= _copterManager.scale3d;
|
x *= _copterManager.scale3d;
|
||||||
@ -167,8 +180,9 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
{
|
{
|
||||||
Geometry = meshwaypoint,
|
Geometry = meshwaypoint,
|
||||||
Transform = new TranslateTransform3D(x, y, z),
|
Transform = new TranslateTransform3D(x, y, z),
|
||||||
Material = MaterialHelper.CreateMaterial(color),
|
Material = new DiffuseMaterial(new SolidColorBrush(color)),
|
||||||
BackMaterial = MaterialHelper.CreateMaterial(color)
|
//Material = MaterialHelper.CreateMaterial(color),
|
||||||
|
// BackMaterial = MaterialHelper.CreateMaterial(color)
|
||||||
};
|
};
|
||||||
|
|
||||||
planeModel3Ds.Add(copter, model3D);
|
planeModel3Ds.Add(copter, model3D);
|
||||||
@ -177,7 +191,7 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
//有飞机在视图里就移动位置
|
//有飞机在视图里就移动位置
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//计算和观测点的相对位置
|
||||||
double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2;
|
double y = GeographyUtils.CalcDistance(0, observationLatLng.Item1, 0, 0, copter.Latitude, 0) / 2;
|
||||||
if (observationLatLng.Item1 > copter.Latitude) y = -y;
|
if (observationLatLng.Item1 > copter.Latitude) y = -y;
|
||||||
|
|
||||||
@ -188,30 +202,45 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
x = Math.Round(x, 2);//按照四舍五入的国际标准
|
x = Math.Round(x, 2);//按照四舍五入的国际标准
|
||||||
y = Math.Round(y, 2);
|
y = Math.Round(y, 2);
|
||||||
double z = Math.Round(copter.Altitude / 2, 2);
|
double z = Math.Round(copter.Altitude / 2, 2);
|
||||||
|
|
||||||
GeometryModel3D panle3D = planeModel3Ds[copter];
|
|
||||||
x *= _copterManager.scale3d;
|
x *= _copterManager.scale3d;
|
||||||
y *= _copterManager.scale3d;
|
y *= _copterManager.scale3d;
|
||||||
z *= _copterManager.scale3d;
|
z *= _copterManager.scale3d;
|
||||||
|
|
||||||
|
//移动飞机到新位置
|
||||||
|
GeometryModel3D panle3D = planeModel3Ds[copter];
|
||||||
|
|
||||||
if (x != panle3D.Transform.Value.OffsetX || y != panle3D.Transform.Value.OffsetY || z != panle3D.Transform.Value.OffsetZ)
|
if (x != panle3D.Transform.Value.OffsetX || y != panle3D.Transform.Value.OffsetY || z != panle3D.Transform.Value.OffsetZ)
|
||||||
{
|
{
|
||||||
panle3D.Transform = new TranslateTransform3D(x, y, z);
|
var trans = panle3D.Transform as TranslateTransform3D;
|
||||||
|
trans.OffsetX = x;
|
||||||
|
trans.OffsetY = y;
|
||||||
|
trans.OffsetZ = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置灯光
|
||||||
|
|
||||||
Color color;
|
Color color;
|
||||||
if (copter.LEDColor != null && copter.LEDColor != "")
|
if (copter.LEDColor != null && copter.LEDColor != "")
|
||||||
{
|
{
|
||||||
color = (Color)ColorConverter.ConvertFromString("#" + copter.LEDColor);
|
color = (Color)ColorConverter.ConvertFromString("#" + copter.LEDColor);
|
||||||
panle3D.Material = MaterialHelper.CreateMaterial(color);
|
panle3D.Material = MaterialHelper.CreateMaterial(color);
|
||||||
panle3D.BackMaterial = MaterialHelper.CreateMaterial(color);
|
// panle3D.BackMaterial = MaterialHelper.CreateMaterial(color);
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
// color = (Color)ColorConverter.ConvertFromString("#" + CopterManager.CopterDefaultColor);
|
/*
|
||||||
|
// Color color;
|
||||||
|
if (copter.LEDShowColor != null)
|
||||||
|
{
|
||||||
|
Color currcolor = System.Windows.Media.Color.FromArgb(
|
||||||
|
copter.LEDShowColor.A, copter.LEDShowColor.R, copter.LEDShowColor.G, copter.LEDShowColor.B);
|
||||||
|
|
||||||
|
{
|
||||||
|
((panle3D.Material as DiffuseMaterial).Brush as SolidColorBrush).Color = currcolor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//Message.Show("添加3D飞机:" + copter.Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -222,16 +251,12 @@ namespace Plane.FormationCreator.ViewModels
|
|||||||
waypointGroup.Children.Clear();
|
waypointGroup.Children.Clear();
|
||||||
if (_flightTaskManager.SelectedTaskIndex > 0)
|
if (_flightTaskManager.SelectedTaskIndex > 0)
|
||||||
{
|
{
|
||||||
//观测点的位置放到最后排飞机的中间位置
|
|
||||||
Tuple<double, double> observationLatLng;
|
|
||||||
|
|
||||||
//列的中间位置
|
//得到观测位置
|
||||||
float midDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
|
if (observationLatLng == null)
|
||||||
|
{
|
||||||
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
getobservationpos();
|
||||||
_flightTaskManager.OriginLat, _flightTaskManager.OriginLng, _flightTaskManager.Orientation + 90, midDistance);
|
}
|
||||||
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
|
||||||
observationLatLng.Item1, observationLatLng.Item2, _flightTaskManager.Orientation + 180, midDistance * 2);
|
|
||||||
|
|
||||||
//modelGroup.Children.Clear();
|
//modelGroup.Children.Clear();
|
||||||
|
|
||||||
|
@ -185,6 +185,19 @@ namespace Plane.FormationCreator.Views
|
|||||||
originalMarker.Position = gmap.FromLocalToLatLng((int)wpPos.X, (int)wpPos.Y);
|
originalMarker.Position = gmap.FromLocalToLatLng((int)wpPos.X, (int)wpPos.Y);
|
||||||
//MapLayer.SetPosition(original, gmap.ViewportPointToLocation(wpPos));
|
//MapLayer.SetPosition(original, gmap.ViewportPointToLocation(wpPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (observerMarker != null && gmap.Markers.Contains(observerMarker))
|
||||||
|
{
|
||||||
|
PointLatLng location = new LatLng(_flightTaskManager.ObserverLat, _flightTaskManager.ObserverLng).ToGCJ02();
|
||||||
|
GPoint wpPos = gmap.FromLatLngToLocal(location);
|
||||||
|
//Point wpPos = gmap.LocationToViewportPoint(location);
|
||||||
|
wpPos.X -= (long)ORIGIN_RADIUS;
|
||||||
|
wpPos.Y -= (long)ORIGIN_RADIUS;
|
||||||
|
observerMarker.Position = gmap.FromLocalToLatLng((int)wpPos.X, (int)wpPos.Y);
|
||||||
|
//MapLayer.SetPosition(original, gmap.ViewportPointToLocation(wpPos));
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GMapMarker rectangleMarker = null;
|
GMapMarker rectangleMarker = null;
|
||||||
@ -278,6 +291,9 @@ namespace Plane.FormationCreator.Views
|
|||||||
|
|
||||||
gmap.MouseMove += new MouseEventHandler(OriginalMove);
|
gmap.MouseMove += new MouseEventHandler(OriginalMove);
|
||||||
gmap.MouseLeftButtonUp += new MouseButtonEventHandler(OriginalMouseUp);
|
gmap.MouseLeftButtonUp += new MouseButtonEventHandler(OriginalMouseUp);
|
||||||
|
|
||||||
|
gmap.MouseMove += new MouseEventHandler(observerMove);
|
||||||
|
gmap.MouseLeftButtonUp += new MouseButtonEventHandler(observerMouseUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
private CopterManager _copterManager = ServiceLocator.Current.GetInstance<CopterManager>();
|
||||||
@ -288,6 +304,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
const string COPTER_TAG = "Copter";
|
const string COPTER_TAG = "Copter";
|
||||||
const string WAYPOINT_TAG = "Waypoint";
|
const string WAYPOINT_TAG = "Waypoint";
|
||||||
const string ORIGINALPOINT_TAG = "Originalpoint";
|
const string ORIGINALPOINT_TAG = "Originalpoint";
|
||||||
|
const string OBSERVER_TAG = "Observerpoint";
|
||||||
|
|
||||||
public void Refresh()
|
public void Refresh()
|
||||||
{
|
{
|
||||||
@ -337,6 +354,8 @@ namespace Plane.FormationCreator.Views
|
|||||||
|
|
||||||
private void Copter_LocationChanged(object sender, EventArgs e)
|
private void Copter_LocationChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!_flightTaskManager.TaskRun_2D) return; //不在3D模式运行直接退出
|
||||||
|
|
||||||
var copter = sender as ICopter;
|
var copter = sender as ICopter;
|
||||||
if (App.Current.CheckAccess())
|
if (App.Current.CheckAccess())
|
||||||
{
|
{
|
||||||
@ -444,7 +463,8 @@ namespace Plane.FormationCreator.Views
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GMapMarker observerMarker = null;
|
||||||
|
Microsoft.Expression.Shapes.RegularPolygon observer = null;
|
||||||
GMapMarker originalMarker = null;
|
GMapMarker originalMarker = null;
|
||||||
Microsoft.Expression.Shapes.RegularPolygon original = null;
|
Microsoft.Expression.Shapes.RegularPolygon original = null;
|
||||||
const double ORIGIN_RADIUS = 12;
|
const double ORIGIN_RADIUS = 12;
|
||||||
@ -483,8 +503,131 @@ namespace Plane.FormationCreator.Views
|
|||||||
_flightTaskManager.OriginLng = location.Lng;
|
_flightTaskManager.OriginLng = location.Lng;
|
||||||
original.MouseLeftButtonDown += new MouseButtonEventHandler(OriginalMouseDown);
|
original.MouseLeftButtonDown += new MouseButtonEventHandler(OriginalMouseDown);
|
||||||
|
|
||||||
|
///加入或者改变观测点用于3D模拟
|
||||||
|
|
||||||
|
if (gmap.Markers.Contains(observerMarker))
|
||||||
|
gmap.Markers.Remove(observerMarker);
|
||||||
|
observer = new Microsoft.Expression.Shapes.RegularPolygon
|
||||||
|
{
|
||||||
|
Tag = OBSERVER_TAG,
|
||||||
|
Fill = new SolidColorBrush(Color.FromArgb(200, 3, 155, 3)),
|
||||||
|
Stroke = new SolidColorBrush(Color.FromArgb(200, 3, 80, 238)),
|
||||||
|
StrokeThickness = 1,
|
||||||
|
Width = ORIGIN_RADIUS *2,
|
||||||
|
Height = ORIGIN_RADIUS * 2,
|
||||||
|
InnerRadius = 1,
|
||||||
|
PointCount = 6,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_flightTaskManager.ObserverLat == 0)
|
||||||
|
{
|
||||||
|
Tuple<double, double> observationLatLng = null;
|
||||||
|
|
||||||
|
|
||||||
|
//第一列到中间的距离
|
||||||
|
float midColDistance = (_flightTaskManager.ColumnCount - 1) * _flightTaskManager.ColumnDistance / 2;
|
||||||
|
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||||
|
_flightTaskManager.OriginLat,
|
||||||
|
_flightTaskManager.OriginLng,
|
||||||
|
_flightTaskManager.Orientation + 90,
|
||||||
|
midColDistance);
|
||||||
|
observationLatLng = GeographyUtils.CalcLatLngSomeMetersAway2D(
|
||||||
|
observationLatLng.Item1,
|
||||||
|
observationLatLng.Item2,
|
||||||
|
_flightTaskManager.Orientation + 180,
|
||||||
|
midColDistance * 4);
|
||||||
|
|
||||||
|
|
||||||
|
_flightTaskManager.ObserverLat = observationLatLng.Item1;
|
||||||
|
_flightTaskManager.ObserverLng = observationLatLng.Item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//_flightTaskManager.ObserverLat = _flightTaskManager.OriginLat;
|
||||||
|
//_flightTaskManager.ObserverLng = _flightTaskManager.OriginLng;
|
||||||
|
|
||||||
|
PointLatLng Observerlocation = new LatLng(_flightTaskManager.ObserverLat, _flightTaskManager.ObserverLng).ToGCJ02();
|
||||||
|
GPoint opoint = gmap.FromLatLngToLocal(Observerlocation);
|
||||||
|
|
||||||
|
opoint.X -= (long)ORIGIN_RADIUS;
|
||||||
|
opoint.Y -= (long)ORIGIN_RADIUS;
|
||||||
|
|
||||||
|
|
||||||
|
mapLocation = gmap.FromLocalToLatLng((int)opoint.X, (int)opoint.Y);
|
||||||
|
|
||||||
|
observerMarker = new GMapMarker(mapLocation);
|
||||||
|
observerMarker.ZIndex = 200;
|
||||||
|
observerMarker.Shape = observer;
|
||||||
|
observerDrag = false;
|
||||||
|
observer.MouseLeftButtonDown += new MouseButtonEventHandler(observerMouseDown);
|
||||||
|
|
||||||
|
|
||||||
|
gmap.Markers.Add(observerMarker);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool observerDrag = false;
|
||||||
|
double observerX = 0;
|
||||||
|
double observerY = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private void observerMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
observerDrag = true;
|
||||||
|
|
||||||
|
gmap.CanDragMap = false;
|
||||||
|
var originPoint = e.GetPosition(gmap);
|
||||||
|
observerX = originPoint.X;
|
||||||
|
observerX = originPoint.Y;
|
||||||
|
|
||||||
|
var posInObject = e.GetPosition(observer);
|
||||||
|
wpOffsetX = posInObject.X;
|
||||||
|
wpOffsetY = posInObject.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void observerMove(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (observerDrag)
|
||||||
|
{
|
||||||
|
Point eventPos = e.GetPosition(gmap);
|
||||||
|
var leftTopPos = new Point(eventPos.X - wpOffsetX, eventPos.Y - wpOffsetY);
|
||||||
|
observerMarker.Position = gmap.FromLocalToLatLng((int)leftTopPos.X, (int)leftTopPos.Y);
|
||||||
|
//MapLayer.SetPosition(original, map.ViewportPointToLocation(leftTopPos));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void observerMouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (observerDrag)
|
||||||
|
{
|
||||||
|
Point eventPos = e.GetPosition(gmap);
|
||||||
|
var centrePos = new Point(eventPos.X - wpOffsetX + ORIGIN_RADIUS, eventPos.Y - wpOffsetY + ORIGIN_RADIUS);
|
||||||
|
PointLatLng location = gmap.FromLocalToLatLng((int)centrePos.X, (int)centrePos.Y);
|
||||||
|
_flightTaskManager.ObserverLat = location.Lat;
|
||||||
|
_flightTaskManager.ObserverLng = location.Lng;
|
||||||
|
// original.ToolTip = location.ToString();
|
||||||
|
//Clipboard.SetDataObject(string.Format("{0},{1}", location.Lat, location.Lng), true);
|
||||||
|
observerDrag = false;
|
||||||
|
gmap.CanDragMap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private bool originaDrag = false;
|
private bool originaDrag = false;
|
||||||
double originX = 0;
|
double originX = 0;
|
||||||
double originY = 0;
|
double originY = 0;
|
||||||
|
@ -39,7 +39,7 @@ namespace Plane.FormationCreator.Views
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetCamera()
|
public void ResetCamera()
|
||||||
{
|
{
|
||||||
// view3d.CameraController.CameraPosition = new Point3D(0, 40, 1);
|
// view3d.CameraController.CameraPosition = new Point3D(0, 40, 1);
|
||||||
// view3d.CameraController.CameraUpDirection = new Vector3D(0, -1, 10);
|
// view3d.CameraController.CameraUpDirection = new Vector3D(0, -1, 10);
|
||||||
@ -49,8 +49,10 @@ namespace Plane.FormationCreator.Views
|
|||||||
|
|
||||||
var camera = view3d.Camera as PerspectiveCamera;
|
var camera = view3d.Camera as PerspectiveCamera;
|
||||||
camera.Position = new Point3D(0, 0, 1);
|
camera.Position = new Point3D(0, 0, 1);
|
||||||
//用于180度
|
//用于朝向180度
|
||||||
camera.LookDirection = new Vector3D(-0.025, -0.911, 0.411);
|
// camera.LookDirection = new Vector3D(-0.025, -0.911, 0.411);
|
||||||
|
//用于朝向9度
|
||||||
|
camera.LookDirection = new Vector3D(0, 1, 0.8);
|
||||||
camera.UpDirection = new Vector3D(0.011, 0.411, 0.912);
|
camera.UpDirection = new Vector3D(0.011, 0.411, 0.912);
|
||||||
|
|
||||||
//用于0度
|
//用于0度
|
||||||
|
Loading…
Reference in New Issue
Block a user