GroundPlaneLayoutConfiguration.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Ximmerse.XR.Tag
  5. {
  6. public enum GroundPlaneMode : byte
  7. {
  8. ground = 0, wall,
  9. }
  10. [System.Serializable]
  11. public class GroundPlaneLayout
  12. {
  13. /// <summary>
  14. /// Ground plane items.
  15. /// </summary>
  16. public GroundPlaneGroup[] groundPlaneGroups;
  17. public bool IsValid()
  18. {
  19. return groundPlaneGroups != null && groundPlaneGroups.Length > 0;
  20. }
  21. }
  22. /// <summary>
  23. /// Ground Plane groups, contains many ground plane items.
  24. /// </summary>
  25. [System.Serializable]
  26. public class GroundPlaneGroup
  27. {
  28. public int groupIndex;
  29. /// <summary>
  30. /// 组下的每个 ground plane item
  31. /// </summary>
  32. public GroundPlaneLayoutItem[] groundPlanes;
  33. }
  34. [System.Serializable]
  35. public class SingleGroundPlaneTechnicalParameter
  36. {
  37. /// <summary>
  38. /// drift recenter angle threshold
  39. /// </summary>
  40. public float drift_recenter_angle_threshold = 1.0f;
  41. /// <summary>
  42. /// drift recenter distance threshold
  43. /// </summary>
  44. public float drift_recenter_distance_threshold = 1.0f;
  45. /// <summary>
  46. /// confidence threshold
  47. /// </summary>
  48. public float confidence_thresh = 0.9f;
  49. /// <summary>
  50. /// min distance threshold
  51. /// </summary>
  52. public float max_distance_thresh = 1.8f;
  53. /// <summary>
  54. /// max distance threshold
  55. /// </summary>
  56. public float min_distance_thresh = 0.1f;
  57. }
  58. /// <summary>
  59. /// Single ground plane item data.
  60. /// </summary>
  61. [System.Serializable]
  62. public class GroundPlaneLayoutItem
  63. {
  64. public int track_id;
  65. public GroundPlaneMode mode;
  66. public Vector3 position;
  67. public Vector3 euler;
  68. public SingleGroundPlaneTechnicalParameter technicalParameter = new SingleGroundPlaneTechnicalParameter();
  69. }
  70. /// <summary>
  71. /// 用于 Fusoin模式下,Ground Plane 的矩阵配置
  72. /// </summary>
  73. [CreateAssetMenu(menuName = "Ximmerse/Ground Plane Layout Config", fileName = "Ground Plane Layout Config")]
  74. public sealed class GroundPlaneLayoutConfiguration : ScriptableObject
  75. {
  76. /// <summary>
  77. /// The ground plane matrix.
  78. /// </summary>
  79. public GroundPlaneLayout layout = new GroundPlaneLayout()
  80. {
  81. groundPlaneGroups = new GroundPlaneGroup[]
  82. {
  83. new GroundPlaneGroup()
  84. {
  85. groupIndex = 0,
  86. groundPlanes = new GroundPlaneLayoutItem[]
  87. {
  88. }
  89. }
  90. }
  91. };
  92. [ContextMenu ("Test : load this config")]
  93. void TestLoadMe()
  94. {
  95. SDKVariants.groundPlaneLayout = layout;
  96. XimmerseXR.LoadGroundPlaneLayout(this.layout);
  97. }
  98. }
  99. }