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.

109 lines
3.9 KiB

4 years ago
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace UnityEngine.XR.ARSubsystems
  4. {
  5. /// <summary>
  6. /// A struct describing face data that is stored in the <see cref="XRFaceSubsystem"/>
  7. /// </summary>
  8. [StructLayout(LayoutKind.Sequential)]
  9. public struct XRFace : ITrackable, IEquatable<XRFace>
  10. {
  11. // Fields to marshall/serialize from native code
  12. TrackableId m_TrackableId;
  13. Pose m_Pose;
  14. TrackingState m_TrackingState;
  15. IntPtr m_NativePtr;
  16. Pose m_LeftEyePose;
  17. Pose m_RightEyePose;
  18. Vector3 m_FixationPoint;
  19. /// <summary>
  20. /// Get a <see cref="XRFace"/> with reasonable default values.
  21. /// </summary>
  22. public static XRFace defaultValue => s_Default;
  23. static readonly XRFace s_Default = new XRFace
  24. {
  25. m_TrackableId = TrackableId.invalidId,
  26. m_Pose = Pose.identity,
  27. m_LeftEyePose = Pose.identity,
  28. m_RightEyePose = Pose.identity,
  29. };
  30. /// <summary>
  31. /// The unique <see cref="TrackableId"/> of the face as a trackable within the <see cref="XRFaceSubsystem"/>.
  32. /// </summary>
  33. /// <remarks>
  34. /// With this, you are able to extract more data about this particular face from the <see cref="XRFaceSubsystem"/>.
  35. /// </remarks>
  36. public TrackableId trackableId => m_TrackableId;
  37. /// <summary>
  38. /// The <see cref="pose"/> of the face describes its position and rotation in session space.
  39. /// </summary>
  40. public Pose pose => m_Pose;
  41. /// <summary>
  42. /// The tracking state associated with this <see cref="XRFace"/>.
  43. /// </summary>
  44. public TrackingState trackingState => m_TrackingState;
  45. /// <summary>
  46. /// A native pointer associated with this <see cref="XRFace"/>.
  47. /// </summary>
  48. /// <remarks>
  49. /// The data pointed to by this pointer is implementation-defined.
  50. /// </remarks>
  51. public IntPtr nativePtr => m_NativePtr;
  52. /// <summary>
  53. /// The pose of the left eye in relation to the face.
  54. /// </summary>
  55. public Pose leftEyePose => m_LeftEyePose;
  56. /// <summary>
  57. /// The pose of the right eye in relation to the face.
  58. /// </summary>
  59. public Pose rightEyePose => m_RightEyePose;
  60. /// <summary>
  61. /// The position of which the eyes are fixated in relation to the face.
  62. /// </summary>
  63. public Vector3 fixationPoint => m_FixationPoint;
  64. // IEquatable boilerplate
  65. public override bool Equals(object obj) => obj is XRFace && Equals((XRFace)obj);
  66. public override int GetHashCode()
  67. {
  68. unchecked
  69. {
  70. var hashCode = trackableId.GetHashCode();
  71. hashCode = (hashCode * 486187739) + pose.GetHashCode();
  72. hashCode = (hashCode * 486187739) + ((int)trackingState).GetHashCode();
  73. hashCode = (hashCode * 486187739) + nativePtr.GetHashCode();
  74. hashCode = (hashCode * 486187739) + leftEyePose.GetHashCode();
  75. hashCode = (hashCode * 486187739) + rightEyePose.GetHashCode();
  76. hashCode = (hashCode * 486187739) + fixationPoint.GetHashCode();
  77. return hashCode;
  78. }
  79. }
  80. public static bool operator==(XRFace lhs, XRFace rhs) => lhs.Equals(rhs);
  81. public static bool operator!=(XRFace lhs, XRFace rhs) => !lhs.Equals(rhs);
  82. public bool Equals(XRFace other)
  83. {
  84. return
  85. trackableId.Equals(other.trackableId) &&
  86. pose.Equals(other.pose) &&
  87. (trackingState == other.trackingState) &&
  88. (nativePtr == other.nativePtr) &&
  89. (leftEyePose.Equals(other.leftEyePose)) &&
  90. (rightEyePose.Equals(other.rightEyePose)) &&
  91. (fixationPoint.Equals(other.fixationPoint));
  92. }
  93. };
  94. }