示例#1
0
            public unsafe override TrackableChanges <XRFace> GetChanges(
                XRFace defaultFace,
                Allocator allocator)
            {
                void *addedPtr, updatedPtr, removedPtr;
                int   addedLength, updatedLength, removedLength, elementSize;
                var   context = UnityARCore_faceTracking_AcquireChanges(
                    out addedPtr, out addedLength,
                    out updatedPtr, out updatedLength,
                    out removedPtr, out removedLength,
                    out elementSize);

                try
                {
                    return(new TrackableChanges <XRFace>(
                               addedPtr, addedLength,
                               updatedPtr, updatedLength,
                               removedPtr, removedLength,
                               defaultFace, elementSize,
                               allocator));
                }
                finally
                {
                    UnityARCore_faceTracking_ReleaseChanges(context);
                }
            }
        static XRFace XRFaceFromIMRFace(IMRFace mrFace)
        {
            var face = new XRFace
            {
                m_TrackableId   = new TrackableId(mrFace.id.subId1, mrFace.id.subId2),
                m_Pose          = mrFace.pose,
                m_TrackingState = TrackingState.Tracking,
#if ARSUBSYSTEMS_3_OR_NEWER
                m_LeftEyePose  = Pose.identity,
                m_RightEyePose = Pose.identity,
#endif
            };

#if ARSUBSYSTEMS_3_OR_NEWER
            if (mrFace.LandmarkPoses.TryGetValue(MRFaceLandmark.LeftEye, out var pose))
            {
                face.m_LeftEyePose = new Pose(pose.position - mrFace.pose.position,
                                              Quaternion.Inverse(mrFace.pose.rotation) * pose.rotation);
            }
            if (mrFace.LandmarkPoses.TryGetValue(MRFaceLandmark.RightEye, out pose))
            {
                face.m_RightEyePose = new Pose(pose.position - mrFace.pose.position,
                                               Quaternion.Inverse(mrFace.pose.rotation) * pose.rotation);
            }
#endif

            return(face);
        }
示例#3
0
        ARFace AddFace(XRFace xrFace)
        {
            var go = CreateGameObject();

            go.layer = gameObject.layer;
            var face = go.GetComponent <ARFace>();

            if (face == null)
            {
                face = go.AddComponent <ARFace>();
            }

            m_Faces.Add(xrFace.trackableId, face);

            return(face);
        }
示例#4
0
 /// <summary>
 /// Get the changes (added, updated, and removed) faces since the last call to <see cref="GetChanges(Allocator)"/>.
 /// </summary>
 /// <param name="defaultFace">
 /// The default face. This should be used to initialize the returned <c>NativeArray</c>s for backwards compatibility.
 /// See <see cref="TrackableChanges{T}.TrackableChanges(void*, int, void*, int, void*, int, T, int, Allocator)"/>.
 /// </param>
 /// <param name="allocator">An <c>Allocator</c> to use when allocating the returned <c>NativeArray</c>s.</param>
 /// <returns>
 /// <see cref="TrackableChanges{T}"/> describing the faces that have been added, updated, and removed
 /// since the last call to <see cref="GetChanges(Allocator)"/>. The changes should be allocated using
 /// <paramref name="allocator"/>.
 /// </returns>
 public abstract TrackableChanges <XRFace> GetChanges(XRFace defaultFace, Allocator allocator);
示例#5
0
 static void UnityARKit_face_anchor_removed(XRFace anchor)
 {
     InvokeFaceRemovedCallback(anchor, s_CurrentInstance);
 }
示例#6
0
 static void UnityARKit_face_anchor_updated(XRFace anchor)
 {
     InvokeFaceUpdatedCallback(anchor, s_CurrentInstance);
 }