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.

119 lines
4.4 KiB

4 years ago
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace UnityEngine.XR.ARSubsystems
  4. {
  5. /// <summary>
  6. /// Contains low-level data for a tracked image in the environment.
  7. /// </summary>
  8. [StructLayout(LayoutKind.Sequential)]
  9. public struct XRTrackedImage : ITrackable, IEquatable<XRTrackedImage>
  10. {
  11. /// <summary>
  12. /// Constructs an <see cref="XRTrackedImage"/>.
  13. /// </summary>
  14. /// <param name="trackableId">The <see cref="TrackableId"/> associated with this tracked image.</param>
  15. /// <param name="sourceImageId">A <c>GUID</c> associated with the source image.</param>
  16. /// <param name="pose">The <c>Pose</c> associated with the detected image.</param>
  17. /// <param name="size">The size (i.e., dimensions) of the detected image.</param>
  18. /// <param name="trackingState">The <see cref="TrackingState"/> of the detected image.</param>
  19. /// <param name="nativePtr">A native pointer associated with the detected image.</param>
  20. public XRTrackedImage(
  21. TrackableId trackableId,
  22. Guid sourceImageId,
  23. Pose pose,
  24. Vector2 size,
  25. TrackingState trackingState,
  26. IntPtr nativePtr)
  27. {
  28. m_Id = trackableId;
  29. m_SourceImageId = sourceImageId;
  30. m_Pose = pose;
  31. m_Size = size;
  32. m_TrackingState = trackingState;
  33. m_NativePtr = nativePtr;
  34. }
  35. /// <summary>
  36. /// Generates a <see cref="XRTrackedImage"/> populated with default values.
  37. /// </summary>
  38. public static XRTrackedImage defaultValue => s_Default;
  39. static readonly XRTrackedImage s_Default = new XRTrackedImage
  40. {
  41. m_Id = TrackableId.invalidId,
  42. m_SourceImageId = Guid.Empty,
  43. m_Pose = Pose.identity,
  44. };
  45. /// <summary>
  46. /// The <see cref="TrackableId"/> associated with this tracked image.
  47. /// </summary>
  48. public TrackableId trackableId => m_Id;
  49. /// <summary>
  50. /// The <c>GUID</c> associated with the source image.
  51. /// </summary>
  52. public Guid sourceImageId => m_SourceImageId;
  53. /// <summary>
  54. /// The <c>Pose</c> associated with this tracked image.
  55. /// </summary>
  56. public Pose pose => m_Pose;
  57. /// <summary>
  58. /// The size (i.e., dimensions) of this tracked image.
  59. /// </summary>
  60. public Vector2 size => m_Size;
  61. /// <summary>
  62. /// The <see cref="TrackingState"/> associated with this tracked image.
  63. /// </summary>
  64. public TrackingState trackingState => m_TrackingState;
  65. /// <summary>
  66. /// A native pointer associated with this tracked image.
  67. /// The data pointed to by this pointer is implementation-defined.
  68. /// While its lifetime is also implementation-defined, it should be
  69. /// valid at least until the next call to
  70. /// <see cref="XRImageTrackingSubsystem.GetChanges(Allocator)"/>.
  71. /// </summary>
  72. public IntPtr nativePtr => m_NativePtr;
  73. public override int GetHashCode()
  74. {
  75. unchecked
  76. {
  77. var hashCode = m_Id.GetHashCode();
  78. hashCode = hashCode * 486187739 + m_SourceImageId.GetHashCode();
  79. hashCode = hashCode * 486187739 + m_Pose.GetHashCode();
  80. hashCode = hashCode * 486187739 + m_Size.GetHashCode();
  81. hashCode = hashCode * 486187739 + m_TrackingState.GetHashCode();
  82. return hashCode;
  83. }
  84. }
  85. public bool Equals(XRTrackedImage other)
  86. {
  87. return
  88. m_Id.Equals(other.m_Id) &&
  89. m_SourceImageId.Equals(other.m_SourceImageId) &&
  90. m_Pose.Equals(other.m_Pose) &&
  91. m_Size.Equals(other.m_Size) &&
  92. m_TrackingState == other.m_TrackingState;
  93. }
  94. public override bool Equals(object obj) => obj is XRTrackedImage && Equals((XRTrackedImage)obj);
  95. public static bool operator==(XRTrackedImage lhs, XRTrackedImage rhs) => lhs.Equals(rhs);
  96. public static bool operator!=(XRTrackedImage lhs, XRTrackedImage rhs) => !lhs.Equals(rhs);
  97. TrackableId m_Id;
  98. Guid m_SourceImageId;
  99. Pose m_Pose;
  100. Vector2 m_Size;
  101. TrackingState m_TrackingState;
  102. IntPtr m_NativePtr;
  103. }
  104. }