SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
5.4 KiB

4 years ago
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace UnityEngine.XR.ARSubsystems
  4. {
  5. /// <summary>
  6. /// Encapsulates all of the data provided for an individual environment probe in an AR session.
  7. /// </summary>
  8. [StructLayout (LayoutKind.Sequential)]
  9. public struct XREnvironmentProbe : IEquatable<XREnvironmentProbe>, ITrackable
  10. {
  11. /// <summary>
  12. /// Creates an <see cref="XREnvironmentProbe"/> populated with default values.
  13. /// </summary>
  14. public static XREnvironmentProbe defaultValue => s_Default;
  15. static readonly XREnvironmentProbe s_Default = new XREnvironmentProbe
  16. {
  17. trackableId = TrackableId.invalidId,
  18. pose = Pose.identity
  19. };
  20. /// <summary>
  21. /// Uniquely identifies each environment probe in an AR session.
  22. /// </summary>
  23. /// <value>
  24. /// The unique trackable ID of the environment probe.
  25. /// </value>
  26. public TrackableId trackableId
  27. {
  28. get => m_TrackableId;
  29. private set => m_TrackableId = value;
  30. }
  31. TrackableId m_TrackableId;
  32. /// <summary>
  33. /// Contains the scale of the environment probe in the AR session.
  34. /// </summary>
  35. /// <value>
  36. /// The scale of the environment probe.
  37. /// </value>
  38. public Vector3 scale
  39. {
  40. get => m_Scale;
  41. private set => m_Scale = value;
  42. }
  43. Vector3 m_Scale;
  44. /// <summary>
  45. /// Contains the pose (position and rotation) of the environment probe in the AR session.
  46. /// </summary>
  47. /// <value>
  48. /// The pose (position and rotation) of the environment probe.
  49. /// </value>
  50. public Pose pose
  51. {
  52. get => m_Pose;
  53. private set => m_Pose = value;
  54. }
  55. Pose m_Pose;
  56. /// <summary>
  57. /// Specifies the volume size around the environment probe's position for use when projecting the environment
  58. /// texture for parallax correction.
  59. /// </summary>
  60. /// <value>
  61. /// The bounding volume size of the environment probe.
  62. /// </value>
  63. /// <remarks>
  64. /// Note that <c>size</c> may validly be infinite.
  65. /// </remarks>
  66. public Vector3 size
  67. {
  68. get => m_Size;
  69. private set => m_Size = value;
  70. }
  71. Vector3 m_Size;
  72. /// <summary>
  73. /// Contains the texture descriptor captured from the device.
  74. /// </summary>
  75. /// <value>
  76. /// The texture descriptor of the environment probe.
  77. /// </value>
  78. /// <remarks>
  79. /// The <c>environmentTextureData</c> value may be invalid indicating that the device has yet to capture an
  80. /// environment texture for this probe. Newly created environment probes have no environment texture. The
  81. /// <see cref="XRTextureDescriptor.valid" /> property should be used to determine whether the texture data
  82. /// is valid.
  83. /// </remarks>
  84. public XRTextureDescriptor textureDescriptor
  85. {
  86. get => m_TextureDescriptor;
  87. private set => m_TextureDescriptor = value;
  88. }
  89. XRTextureDescriptor m_TextureDescriptor;
  90. /// <summary>
  91. /// The <see cref="TrackingState"/> associated with this environment probe.
  92. /// </summary>
  93. public TrackingState trackingState
  94. {
  95. get => m_TrackingState;
  96. private set => m_TrackingState = value;
  97. }
  98. TrackingState m_TrackingState;
  99. /// <summary>
  100. /// A native pointer associated with this environment probe.
  101. /// The data pointed to by this pointer is implementation-defined. Its lifetime
  102. /// is also implementation-defined, but will be valid at least until the next
  103. /// call to <see cref="XREnvironmentProbeSubsystem.GetChanges(Allocator)"/>.
  104. /// </summary>
  105. public IntPtr nativePtr
  106. {
  107. get => m_NativePtr;
  108. private set => m_NativePtr = value;
  109. }
  110. IntPtr m_NativePtr;
  111. public bool Equals(XREnvironmentProbe other)
  112. {
  113. // Environment probes are equivalent if the trackable IDs match.
  114. return m_TrackableId.Equals(other.m_TrackableId);
  115. }
  116. public override bool Equals(System.Object obj)
  117. {
  118. return (!ReferenceEquals(obj, null)
  119. && (ReferenceEquals(this, obj)
  120. || ((obj is XREnvironmentProbe) && Equals((XREnvironmentProbe)obj))));
  121. }
  122. public static bool operator ==(XREnvironmentProbe lhs, XREnvironmentProbe rhs) => lhs.Equals(rhs);
  123. public static bool operator !=(XREnvironmentProbe lhs, XREnvironmentProbe rhs) => !(lhs == rhs);
  124. public override int GetHashCode() => m_TrackableId.GetHashCode();
  125. public override string ToString() => ToString("0.000");
  126. public string ToString(string floatingPointformat)
  127. {
  128. return string.Format("{0} scale:{1} pose:{2} size:{3} environmentTextureData:{4} trackingState:{5} nativePtr:{6}",
  129. m_TrackableId.ToString(), m_Scale.ToString(floatingPointformat),
  130. m_Pose.ToString(floatingPointformat), m_Size.ToString(floatingPointformat),
  131. m_TextureDescriptor.ToString(), m_TrackingState.ToString(), m_NativePtr.ToString());
  132. }
  133. }
  134. }