Browse Source

人员定位检测方法优化

develop
杨栋梁 11 months ago
parent
commit
d1e653c997
  1. 26
      Assets/LongZhiMeng/Prefab/ShiNei/nei-5.prefab
  2. 60
      Assets/Scenes/MainScene.unity
  3. BIN
      Assets/Scenes/MainScene/NavMesh-NavmeshSurface.asset
  4. 52
      Assets/Scripts/Main/Core/PersonnelLocation/LocationSimulator.cs
  5. 4
      Assets/Scripts/Main/Core/PersonnelLocation/PositionData.cs
  6. 2
      ProjectSettings/NavMeshAreas.asset
  7. 2
      ProjectSettings/TagManager.asset

26
Assets/LongZhiMeng/Prefab/ShiNei/nei-5.prefab

@ -1008,7 +1008,7 @@ GameObject:
- component: {fileID: 8736513398244836139}
- component: {fileID: 3076020743435447431}
- component: {fileID: 2883135339924689476}
m_Layer: 9
m_Layer: 15
m_Name: LT80
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -1638,7 +1638,7 @@ GameObject:
- component: {fileID: 8270513691876896516}
- component: {fileID: 5796460198407872174}
- component: {fileID: 2856167908211855524}
m_Layer: 9
m_Layer: 15
m_Name: LT79
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -2469,7 +2469,7 @@ GameObject:
- component: {fileID: 6292780013325109327}
- component: {fileID: 5710179564857778156}
- component: {fileID: 6761258167639674638}
m_Layer: 9
m_Layer: 15
m_Name: LT85
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -3517,7 +3517,7 @@ GameObject:
- component: {fileID: 4065088276986826924}
- component: {fileID: 4920687918572847181}
- component: {fileID: 8253019813129201132}
m_Layer: 9
m_Layer: 15
m_Name: LT81
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -3915,7 +3915,7 @@ GameObject:
- component: {fileID: 8849098653514059089}
- component: {fileID: 3769855221563518552}
- component: {fileID: 6044842954695581892}
m_Layer: 9
m_Layer: 15
m_Name: LT78
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -7264,7 +7264,7 @@ GameObject:
- component: {fileID: 4706818223685031804}
- component: {fileID: 2867885534027382574}
- component: {fileID: 7385417565108069315}
m_Layer: 9
m_Layer: 15
m_Name: LT82
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -7469,7 +7469,7 @@ GameObject:
- component: {fileID: 6698358921822060760}
- component: {fileID: 190428641712663357}
- component: {fileID: 1979830499400582886}
m_Layer: 9
m_Layer: 15
m_Name: LT76
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -10057,7 +10057,7 @@ GameObject:
- component: {fileID: 5606630640673256000}
- component: {fileID: 3336034004680812250}
- component: {fileID: 8373291608014601901}
m_Layer: 9
m_Layer: 15
m_Name: LT86
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -10506,7 +10506,7 @@ GameObject:
- component: {fileID: 7713560582214749036}
- component: {fileID: 2777961242466473191}
- component: {fileID: 8395288681916190803}
m_Layer: 9
m_Layer: 15
m_Name: LT77
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -11776,7 +11776,7 @@ GameObject:
- component: {fileID: 6687785829109330241}
- component: {fileID: 1696386882297568433}
- component: {fileID: 2639579858283849929}
m_Layer: 9
m_Layer: 15
m_Name: LT83
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -13222,7 +13222,7 @@ GameObject:
- component: {fileID: 4133104752455562498}
- component: {fileID: 7568392748715444118}
- component: {fileID: 8091224218162497660}
m_Layer: 9
m_Layer: 15
m_Name: LT87
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -13462,7 +13462,7 @@ GameObject:
- component: {fileID: 1025057594082597017}
- component: {fileID: 2356675421490092156}
- component: {fileID: 7897323096907996761}
m_Layer: 9
m_Layer: 15
m_Name: LT84
m_TagString: Untagged
m_Icon: {fileID: 0}
@ -14298,7 +14298,7 @@ GameObject:
- component: {fileID: 5483656822029382327}
- component: {fileID: 150361346221733946}
- component: {fileID: 4315962088187642190}
m_Layer: 9
m_Layer: 15
m_Name: LT88
m_TagString: Untagged
m_Icon: {fileID: 0}

60
Assets/Scenes/MainScene.unity

@ -592,6 +592,66 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &769910639
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 769910641}
- component: {fileID: 769910640}
m_Layer: 0
m_Name: NavmeshSurface
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &769910640
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 769910639}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a5ac11cc976e418e8d13136b07e1f52, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AgentTypeID: 0
m_CollectObjects: 0
m_Size: {x: 10, y: 10, z: 10}
m_Center: {x: 0, y: 2, z: 0}
m_LayerMask:
serializedVersion: 2
m_Bits: 16384
m_UseGeometry: 0
m_DefaultArea: 0
m_IgnoreNavMeshAgent: 1
m_IgnoreNavMeshObstacle: 1
m_OverrideTileSize: 0
m_TileSize: 256
m_OverrideVoxelSize: 0
m_VoxelSize: 0.06666667
m_BuildHeightMesh: 0
m_NavMeshData: {fileID: 23800000, guid: c43d6f4c8df752448b293354558290a5, type: 2}
--- !u!4 &769910641
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 769910639}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &778059118
GameObject:
m_ObjectHideFlags: 0

BIN
Assets/Scenes/MainScene/NavMesh-NavmeshSurface.asset

Binary file not shown.

52
Assets/Scripts/Main/Core/PersonnelLocation/LocationSimulator.cs

@ -255,16 +255,16 @@ public class LocationSimulator : MonoBehaviour
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
//public float SetY(Vector3 position)
//{
// RaycastHit hit;
// if (Physics.Raycast(position, Vector3.down, out hit, Mathf.Infinity, layerMask))
// {
// // 如果射线击中地面,设置Y轴为地面高度
// return hit.point.y;
// }
// return 0f;
//}
public float SetY(Vector3 position)
{
RaycastHit hit;
if (Physics.Raycast(position, Vector3.down, out hit, Mathf.Infinity, LayerMask.NameToLayer("Stair")))
{
// 如果射线击中地面,设置Y轴为地面高度
return hit.point.y;
}
return 0f;
}
/// <summary>
/// 创建agent对象
@ -313,8 +313,36 @@ public class LocationSimulator : MonoBehaviour
/// <returns></returns>
public Vector3 ConversionTransform(LocationData data)
{
var pos = new Vector3(-((float)data.xAxis - offsetX), -17.7f, -((float)data.yAxis - offsetZ));
//pos.y = SetY(pos);
//判断数据被检测到的区域
string St1 = "106";//楼梯入口基站
string St2 = "107";//楼梯间基站
string St3 = "108";//楼梯底层基站
//纠正坐标
Vector3 p1 = new Vector3(-15.48f, -17.7f, 41.83f);//1.7
Vector3 p2 = new Vector3(-15.48f, -19.3f, 37.48f);//1.4
Vector3 p3 = new Vector3(-17.47f, -19.3f, 37.48f);//1.4
Vector3 p4 = new Vector3(-17.47f, -21.1f, 42.42f);//1.7
//换算最终位置
//-4地面高度-17.7f
float y = -17.7f;
var pos = new Vector3(-((float)data.xAxis - offsetX), y, -((float)data.yAxis - offsetZ));
if (data.stations.Contains(St3) && !data.stations.Contains(St2))
{ //-5地面高度-21.1f
pos.y = -21.1f;
}
else if (data.stations.Contains(St1) && data.stations.Contains(St2))
{ //-4到-5楼梯上半段
pos.y = SetY(pos);
}
else if (data.stations.Contains(St2) && data.stations.Contains(St3))
{ //-4到-5楼梯下半段
pos.y = SetY(pos);
}
else if (data.stations.Contains(St2) && !data.stations.Contains(St1) && !data.stations.Contains(St3))
{
//-4到-5楼梯间过度
pos.y = -19.3f;
}
return pos;
}

4
Assets/Scripts/Main/Core/PersonnelLocation/PositionData.cs

@ -4,7 +4,7 @@ using System.Collections.Generic;
public class PositionData
{
public int errorCode;
public List<LocationData> list;
public List<LocationData> list;//不同定位卡对应的位置信息
}
[Serializable]
public class LocationData
@ -23,7 +23,7 @@ public class LocationData
public long createdTime;
//标签编号
public long targetNo;
public string stations;
public string stations;//检测到当前定位卡的基站们
}

2
ProjectSettings/NavMeshAreas.asset

@ -73,7 +73,7 @@ NavMeshProjectSettings:
m_Settings:
- serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentRadius: 0.2
agentHeight: 2
agentSlope: 45
agentClimb: 0.75

2
ProjectSettings/TagManager.asset

@ -23,7 +23,7 @@ TagManager:
- Minimap
- Annotation
- Floor
-
- Stair
-
-
-

Loading…
Cancel
Save