TagGroundPlane.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using static Ximmerse.XR.PluginVioFusion;
  4. namespace Ximmerse.XR.Tag
  5. {
  6. /// <summary>
  7. /// A component that implements the large spatial positioning function, including the field properties required by the function.
  8. /// </summary>
  9. [AddComponentMenu("Ximmerse XR/Tag Ground Plane")]
  10. public class TagGroundPlane : GroundSpace
  11. {
  12. #region Property
  13. internal static List<TagGroundPlane> tagGroundPlaneList = new List<TagGroundPlane>();
  14. private int m_beaconCoordSystemFlag = 1;
  15. private float timer = 0;
  16. public int TrackId
  17. {
  18. get => trackID;
  19. set => trackID = value;
  20. }
  21. public bool DebugView
  22. {
  23. get => m_debugView;
  24. set => m_debugView = value;
  25. }
  26. public float Size
  27. {
  28. get => m_size;
  29. set => m_size = value;
  30. }
  31. public float BeaconDriftRecenterDistanceThreshold
  32. {
  33. get => m_distance;
  34. set => m_distance = value;
  35. }
  36. public float BeaconDriftRecenterAngleThreshold
  37. {
  38. get => m_angle;
  39. set => m_angle = value;
  40. }
  41. public float BeaconConfidenceThresh
  42. {
  43. get => m_Confidence;
  44. set => m_Confidence = value;
  45. }
  46. public float BeaconMinDistanceThresh
  47. {
  48. get => m_minDistance;
  49. set => m_minDistance = value;
  50. }
  51. public float BeaconMaxDistanceThresh
  52. {
  53. get => m_maxDistance;
  54. set => m_maxDistance = value;
  55. }
  56. public int BeaconCoordSystemFlag
  57. {
  58. get => m_beaconCoordSystemFlag;
  59. set => m_beaconCoordSystemFlag = value;
  60. }
  61. private XAttrBeaconInWorldInfo SetBeaconFusion()
  62. {
  63. //< ÉèÖÃbeacon µ½ vio fusion£¬Æ½·Å
  64. Vector3 pos = FixXRPosition();
  65. Quaternion rot = FixXRRotation();
  66. XAttrBeaconInWorldInfo beacon_in_world_info = new XAttrBeaconInWorldInfo(trackID);
  67. beacon_in_world_info.drift_recenter_angle_threshold = BeaconDriftRecenterAngleThreshold;
  68. beacon_in_world_info.drift_recenter_distance_threshold = BeaconDriftRecenterDistanceThreshold;
  69. beacon_in_world_info.group_id = -1;
  70. beacon_in_world_info.coord_system_flag = BeaconCoordSystemFlag; //0=right hand coord system, 1 = left hand coord system
  71. beacon_in_world_info.confidence_thresh = BeaconConfidenceThresh;
  72. beacon_in_world_info.max_distance_thresh = BeaconMaxDistanceThresh;
  73. beacon_in_world_info.min_distance_thresh = BeaconMinDistanceThresh;
  74. beacon_in_world_info.beacon_id = trackID;
  75. beacon_in_world_info.rotation[0] = rot.x;
  76. beacon_in_world_info.rotation[1] = rot.y;
  77. beacon_in_world_info.rotation[2] = rot.z;
  78. beacon_in_world_info.rotation[3] = rot.w;
  79. beacon_in_world_info.position[0] = pos.x;
  80. beacon_in_world_info.position[1] = pos.y;
  81. beacon_in_world_info.position[2] = pos.z;
  82. return beacon_in_world_info;
  83. }
  84. public XAttrBeaconInWorldInfo beacon_info
  85. {
  86. get => SetBeaconFusion();
  87. }
  88. /// <summary>
  89. /// tracking state
  90. /// </summary>
  91. public bool isTracking
  92. {
  93. get => IsTracking();
  94. }
  95. protected override void Awake()
  96. {
  97. tagGroundPlaneList.Add(this);
  98. }
  99. protected override void OnDestroy()
  100. {
  101. tagGroundPlaneList.Remove(this);
  102. }
  103. #endregion
  104. }
  105. }