private VuforiaManagerImpl.TrackableResultData GetTrackableResultData(VuforiaManager.TrackableIdPair trackableId, bool includeVuMarks)
 {
     VuforiaManagerImpl.TrackableResultData[] array = this.mTrackableResultDataArray;
     for (int i = 0; i < array.Length; i++)
     {
         VuforiaManagerImpl.TrackableResultData trackableResultData = array[i];
         if (trackableResultData.id == trackableId.TrackableId)
         {
             return(trackableResultData);
         }
     }
     VuforiaManagerImpl.TrackableResultData result;
     result.id            = -1;
     result.pose          = default(VuforiaManagerImpl.PoseData);
     result.statusInteger = 1;
     result.timeStamp     = 0.0;
     if (includeVuMarks)
     {
         VuforiaManagerImpl.VuMarkTargetResultData[] array2 = this.mVuMarkResultDataArray;
         for (int i = 0; i < array2.Length; i++)
         {
             VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = array2[i];
             if (vuMarkTargetResultData.resultID == trackableId.ResultId)
             {
                 result.id            = vuMarkTargetResultData.resultID;
                 result.statusInteger = vuMarkTargetResultData.statusInteger;
                 result.pose          = vuMarkTargetResultData.pose;
                 result.timeStamp     = vuMarkTargetResultData.timeStamp;
                 break;
             }
         }
     }
     return(result);
 }
 private void UpdateTrackableFoundQueue()
 {
     VuforiaManagerImpl.TrackableResultData[] array = this.mTrackableResultDataArray;
     for (int i = 0; i < array.Length; i++)
     {
         VuforiaManagerImpl.TrackableResultData trackableResultData = array[i];
         this.UpdateTrackableFoundQueue(trackableResultData.status, VuforiaManager.TrackableIdPair.FromTrackableId(trackableResultData.id));
     }
     VuforiaManagerImpl.VuMarkTargetResultData[] array2 = this.mVuMarkResultDataArray;
     for (int i = 0; i < array2.Length; i++)
     {
         VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = array2[i];
         this.UpdateTrackableFoundQueue(vuMarkTargetResultData.status, VuforiaManager.TrackableIdPair.FromResultId(vuMarkTargetResultData.resultID));
     }
     using (List <VuforiaManager.TrackableIdPair> .Enumerator enumerator = new List <VuforiaManager.TrackableIdPair>(this.mTrackableFoundQueue).GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             VuforiaManager.TrackableIdPair id = enumerator.Current;
             if (Array.Exists <VuforiaManagerImpl.TrackableResultData>(this.mTrackableResultDataArray, (VuforiaManagerImpl.TrackableResultData tr) => tr.id == id.TrackableId))
             {
                 break;
             }
             if (Array.Exists <VuforiaManagerImpl.VuMarkTargetResultData>(this.mVuMarkResultDataArray, (VuforiaManagerImpl.VuMarkTargetResultData tr) => tr.resultID == id.ResultId))
             {
                 break;
             }
             this.mTrackableFoundQueue.Remove(id);
         }
     }
 }
Ejemplo n.º 3
0
        private void ResetExtendedTrackingForTrackable(int trackableID)
        {
            IHoloLensApiAbstraction holoLensApiAbstraction = VuforiaUnity.GetHoloLensApiAbstraction();

            VuforiaManager.TrackableIdPair[] array = this.mTrackablesCurrentlyExtendedTracked.Keys.ToArray <VuforiaManager.TrackableIdPair>();
            for (int i = 0; i < array.Length; i++)
            {
                VuforiaManager.TrackableIdPair trackableIdPair = array[i];
                if (trackableIdPair.TrackableId == trackableID)
                {
                    this.mTrackablesCurrentlyExtendedTracked.Remove(trackableIdPair);
                    holoLensApiAbstraction.DeleteWorldAnchor(trackableIdPair);
                    if (this.mExtendedTrackablesState.ContainsKey(trackableIdPair))
                    {
                        this.mExtendedTrackablesState.Remove(trackableIdPair);
                    }
                }
            }
            array = this.mTrackingList.Keys.ToArray <VuforiaManager.TrackableIdPair>();
            for (int i = 0; i < array.Length; i++)
            {
                VuforiaManager.TrackableIdPair trackableIdPair2 = array[i];
                if (trackableIdPair2.TrackableId == trackableID)
                {
                    this.mTrackingList.Remove(trackableIdPair2);
                }
            }
        }
Ejemplo n.º 4
0
        private bool TryGetBehaviour(VuforiaManager.TrackableIdPair trackableId, out TrackableBehaviour trackableBehaviour)
        {
            if (trackableId.ResultId >= 0)
            {
                using (List <VuMarkAbstractBehaviour> .Enumerator enumerator = this.mVuMarkManager.GetActiveBehaviours().ToList <VuMarkAbstractBehaviour>().GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        VuMarkAbstractBehaviour current = enumerator.Current;
                        if (current.VuMarkResultId == trackableId.ResultId)
                        {
                            trackableBehaviour = current;
                            return(true);
                        }
                    }
                    goto IL_6A;
                }
                goto IL_57;
IL_6A:
                trackableBehaviour = null;
                return(false);
            }
IL_57:
            return(this.mTrackableBehaviours.TryGetValue(trackableId.TrackableId, out trackableBehaviour));
        }
Ejemplo n.º 5
0
 private void OnSpatialAnchorTrackingCallback(VuforiaManager.TrackableIdPair trackableResultID, bool tracked)
 {
     if (tracked)
     {
         this.mExtendedTrackablesState[trackableResultID] = TrackableBehaviour.Status.EXTENDED_TRACKED;
         return;
     }
     this.mExtendedTrackablesState[trackableResultID] = TrackableBehaviour.Status.NOT_FOUND;
 }
 private void UpdateTrackableFoundQueue(TrackableBehaviour.Status status, VuforiaManager.TrackableIdPair trackableId)
 {
     if (VuforiaManagerImpl.IsDetectedOrTracked(status))
     {
         if (!this.mTrackableFoundQueue.Contains(trackableId))
         {
             this.mTrackableFoundQueue.AddLast(trackableId);
             return;
         }
     }
     else if (this.mTrackableFoundQueue.Contains(trackableId))
     {
         this.mTrackableFoundQueue.Remove(trackableId);
     }
 }
        private void UpdateTrackers(VuforiaManagerImpl.FrameState frameState)
        {
            this.UnmarshalTrackables(frameState);
            this.UnmarshalWordTrackables(frameState);
            this.UnmarshalVuMarkTrackables(frameState);
            this.UpdateTrackableFoundQueue();
            StateManagerImpl stateManagerImpl = (StateManagerImpl)TrackerManager.Instance.GetStateManager();

            this.UpdateSmartTerrain(frameState, stateManagerImpl);
            this.UpdateExtendedTrackedVuMarks();
            stateManagerImpl.UpdateVuMarks(this.mVuMarkDataArray, this.mVuMarkResultDataArray);
            VuforiaManager.TrackableIdPair trackableIdPair = new VuforiaManager.TrackableIdPair
            {
                ResultId    = -1,
                TrackableId = -1
            };
            int num = -1;

            if (this.mWorldCenterMode == VuforiaARController.WorldCenterMode.SPECIFIC_TARGET)
            {
                if (this.mVuMarkWorldCenter != null && this.mVuMarkWorldCenter.VuMarkTemplate != null)
                {
                    this.mWorldCenter = this.GetVuMarkWorldCenter(this.mVuMarkWorldCenter.VuMarkTemplate.ID);
                }
                if (this.mWorldCenter != null && this.mWorldCenter.Trackable != null)
                {
                    if (this.mWorldCenter is VuMarkAbstractBehaviour)
                    {
                        trackableIdPair.ResultId = ((VuMarkAbstractBehaviour)this.mWorldCenter).VuMarkResultId;
                    }
                    else
                    {
                        trackableIdPair.TrackableId = this.mWorldCenter.Trackable.ID;
                    }
                }
            }
            else if (this.mWorldCenterMode == VuforiaARController.WorldCenterMode.FIRST_TARGET)
            {
                stateManagerImpl.RemoveDisabledTrackablesFromQueue(ref this.mTrackableFoundQueue);
                if (this.mTrackableFoundQueue.Count > 0)
                {
                    trackableIdPair = this.mTrackableFoundQueue.First.Value;
                }
            }
            else if (this.mWorldCenterMode == VuforiaARController.WorldCenterMode.DEVICE_TRACKING)
            {
                num = frameState.deviceTrackableId;
            }
            DeviceTrackingManager deviceTrackingManager = stateManagerImpl.GetDeviceTrackingManager();

            if (num != -1)
            {
                deviceTrackingManager.UpdateCamera(this.mCentralAnchorPoint, this.mTrackableResultDataArray, num);
            }
            else
            {
                RotationalPlayModeDeviceTrackerImpl rotationalPlayModeDeviceTrackerImpl = TrackerManager.Instance.GetTracker <DeviceTracker>() as RotationalPlayModeDeviceTrackerImpl;
                if (rotationalPlayModeDeviceTrackerImpl != null && rotationalPlayModeDeviceTrackerImpl.IsActive)
                {
                    VuforiaManagerImpl.TrackableResultData trackable = rotationalPlayModeDeviceTrackerImpl.GetTrackable();
                    deviceTrackingManager.UpdateCamera(this.mCentralAnchorPoint, new VuforiaManagerImpl.TrackableResultData[]
                    {
                        trackable
                    }, trackable.id);
                }
                else if (trackableIdPair.TrackableId >= 0 || trackableIdPair.ResultId >= 0)
                {
                    VuforiaManagerImpl.TrackableResultData trackableResultData = this.GetTrackableResultData(trackableIdPair, true);
                    if (VuforiaManagerImpl.IsDetectedOrTracked(trackableResultData.status))
                    {
                        stateManagerImpl.UpdateCameraPoseWRTTrackable(this.mCentralAnchorPoint, this.mParentAnchorPoint, trackableIdPair, trackableResultData.pose);
                    }
                }
            }
            if (this.mARCameraTransform != this.mCentralAnchorPoint)
            {
                this.mARCameraTransform.position = this.mCentralAnchorPoint.position;
                this.mARCameraTransform.rotation = this.mCentralAnchorPoint.rotation;
            }
            stateManagerImpl.UpdateTrackablePoses(this.mARCameraTransform, this.mTrackableResultDataArray, this.mVuMarkResultDataArray, trackableIdPair, frameState.frameIndex);
            stateManagerImpl.UpdateWords(this.mARCameraTransform, this.mWordDataArray, this.mWordResultDataArray);
            stateManagerImpl.UpdateVirtualButtons(frameState.numVirtualButtonResults, frameState.vbDataArray);
        }
        private void UpdateExtendedTrackedVuMarks()
        {
            StateManagerImpl expr_0F = (StateManagerImpl)TrackerManager.Instance.GetStateManager();

            VuforiaManager.TrackableIdPair[] array = expr_0F.GetExtendedTrackingManager().GetExtendedTrackedBehaviours().ToArray <VuforiaManager.TrackableIdPair>();
            VuMarkManagerImpl vuMarkManagerImpl    = (VuMarkManagerImpl)expr_0F.GetVuMarkManager();
            List <int>        list = new List <int>();

            for (int i = 0; i < this.mVuMarkResultDataArray.Length; i++)
            {
                list.Add(this.mVuMarkResultDataArray[i].resultID);
            }
            Dictionary <int, List <int> > dictionary = new Dictionary <int, List <int> >();

            VuforiaManager.TrackableIdPair[] array2 = array;
            for (int j = 0; j < array2.Length; j++)
            {
                int resultId = array2[j].ResultId;
                VuMarkAbstractBehaviour behaviourWithResultID = vuMarkManagerImpl.GetBehaviourWithResultID(resultId);
                if (behaviourWithResultID != null)
                {
                    int iD = behaviourWithResultID.VuMarkTarget.ID;
                    if (!list.Contains(resultId))
                    {
                        if (!dictionary.ContainsKey(iD))
                        {
                            dictionary[iD] = new List <int>();
                        }
                        dictionary[iD].Add(resultId);
                    }
                    else
                    {
                        list.Remove(resultId);
                    }
                }
            }
            for (int k = 0; k < this.mVuMarkResultDataArray.Length; k++)
            {
                int targetID = this.mVuMarkResultDataArray[k].targetID;
                int resultID = this.mVuMarkResultDataArray[k].resultID;
                if (list.Contains(resultID) && dictionary.ContainsKey(targetID))
                {
                    List <int> list2 = dictionary[targetID];
                    if (list2.Count > 0)
                    {
                        int num = list2[list2.Count - 1];
                        list2.RemoveAt(list2.Count - 1);
                        Debug.Log(string.Concat(new object[]
                        {
                            "CHANGE RESULT ID ",
                            this.mVuMarkResultDataArray[k].resultID,
                            " => ",
                            num
                        }));
                        this.mVuMarkResultDataArray[k].resultID = num;
                    }
                }
            }
            List <VuforiaManagerImpl.VuMarkTargetResultData> list3 = this.mVuMarkResultDataArray.ToList <VuforiaManagerImpl.VuMarkTargetResultData>();

            array2 = array;
            for (int j = 0; j < array2.Length; j++)
            {
                VuforiaManager.TrackableIdPair trackableIdPair = array2[j];
                if (trackableIdPair.ResultId >= 0)
                {
                    bool flag = false;
                    VuforiaManagerImpl.VuMarkTargetResultData[] array3 = this.mVuMarkResultDataArray;
                    for (int l = 0; l < array3.Length; l++)
                    {
                        if (array3[l].resultID == trackableIdPair.ResultId)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        VuMarkAbstractBehaviour behaviourWithResultID2 = vuMarkManagerImpl.GetBehaviourWithResultID(trackableIdPair.ResultId);
                        list3.Add(new VuforiaManagerImpl.VuMarkTargetResultData
                        {
                            pose = new VuforiaManagerImpl.PoseData
                            {
                                coordinateSystem = TrackableBehaviour.CoordinateSystem.WORLD,
                                position         = behaviourWithResultID2.transform.position,
                                orientation      = behaviourWithResultID2.transform.rotation * Quaternion.AngleAxis(90f, Vector3.right)
                            },
                            resultID = trackableIdPair.ResultId,
                            targetID = behaviourWithResultID2.VuMarkTarget.ID,
                            status   = TrackableBehaviour.Status.EXTENDED_TRACKED
                        });
                    }
                }
            }
            this.mVuMarkResultDataArray = list3.ToArray();
            HashSet <int> hashSet = new HashSet <int>();

            array2 = array;
            for (int j = 0; j < array2.Length; j++)
            {
                VuforiaManager.TrackableIdPair trackableIdPair2 = array2[j];
                if (trackableIdPair2.ResultId >= 0)
                {
                    VuMarkAbstractBehaviour behaviourWithResultID3 = vuMarkManagerImpl.GetBehaviourWithResultID(trackableIdPair2.ResultId);
                    if (behaviourWithResultID3 != null && behaviourWithResultID3.VuMarkTarget != null)
                    {
                        hashSet.Add(behaviourWithResultID3.VuMarkTarget.ID);
                    }
                }
            }
            List <VuforiaManagerImpl.VuMarkTargetData> list4 = new List <VuforiaManagerImpl.VuMarkTargetData>();

            for (int m = 0; m < this.mVuMarkDataArray.Length; m++)
            {
                int id = this.mVuMarkDataArray[m].id;
                if (!hashSet.Contains(id))
                {
                    list4.Add(this.mVuMarkDataArray[m]);
                }
            }
            this.mVuMarkDataArray = list4.ToArray();
        }
Ejemplo n.º 9
0
 public void DeleteWorldAnchor(VuforiaManager.TrackableIdPair trackableID)
 {
 }
Ejemplo n.º 10
0
 public void SetWorldAnchor(TrackableBehaviour trackableBehaviour, VuforiaManager.TrackableIdPair trackableID)
 {
 }
Ejemplo n.º 11
0
        internal void UpdateTrackablePoses(Transform arCameraTransform, VuforiaManagerImpl.TrackableResultData[] trackableResultDataArray, VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResultDataArray, VuforiaManager.TrackableIdPair originTrackableID, int frameIndex)
        {
            Dictionary <int, TrackableBehaviour.Status> dictionary = new Dictionary <int, TrackableBehaviour.Status>();

            for (int i = 0; i < trackableResultDataArray.Length; i++)
            {
                VuforiaManagerImpl.TrackableResultData trackableResultData = trackableResultDataArray[i];
                dictionary.Add(trackableResultData.id, trackableResultData.status);
                TrackableBehaviour trackableBehaviour;
                if (this.mTrackableBehaviours.TryGetValue(trackableResultData.id, out trackableBehaviour) && trackableResultData.id != originTrackableID.TrackableId && VuforiaManagerImpl.IsDetectedOrTracked(trackableResultData.status) && trackableBehaviour.enabled)
                {
                    StateManagerImpl.PositionTrackable(trackableBehaviour, arCameraTransform, trackableResultData.pose, trackableResultData.timeStamp);
                }
            }
            Dictionary <int, TrackableBehaviour.Status> dictionary2 = new Dictionary <int, TrackableBehaviour.Status>();

            for (int i = 0; i < vuMarkResultDataArray.Length; i++)
            {
                VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = vuMarkResultDataArray[i];
                dictionary2.Add(vuMarkTargetResultData.resultID, vuMarkTargetResultData.status);
            }
            this.mVuMarkManager.UpdateVuMarkPoses(arCameraTransform, vuMarkResultDataArray, originTrackableID.ResultId);
            this.mActiveTrackableBehaviours.Clear();
            TrackableBehaviour[] array = this.GetTrackableBehaviours().ToArray <TrackableBehaviour>();
            for (int i = 0; i < array.Length; i++)
            {
                TrackableBehaviour trackableBehaviour2 = array[i];
                if (trackableBehaviour2.enabled)
                {
                    TrackableBehaviour.Status vuforiaStatus;
                    if (dictionary.TryGetValue(trackableBehaviour2.Trackable.ID, out vuforiaStatus) || (trackableBehaviour2 is VuMarkAbstractBehaviour && dictionary2.TryGetValue(((VuMarkAbstractBehaviour)trackableBehaviour2).VuMarkResultId, out vuforiaStatus)))
                    {
                        this.mExtendedTrackingManager.ApplyTrackingState(trackableBehaviour2, vuforiaStatus, arCameraTransform);
                        trackableBehaviour2.OnFrameIndexUpdate(frameIndex);
                    }
                    else
                    {
                        this.mExtendedTrackingManager.ApplyTrackingState(trackableBehaviour2, TrackableBehaviour.Status.NOT_FOUND, arCameraTransform);
                    }
                    if (VuforiaManagerImpl.IsDetectedOrTracked(trackableBehaviour2.CurrentStatus))
                    {
                        this.mActiveTrackableBehaviours.Add(trackableBehaviour2);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        internal void UpdateCameraPoseWRTTrackable(Transform cameraTransform, Transform parentTransformToUpdate, VuforiaManager.TrackableIdPair trackableId, VuforiaManagerImpl.PoseData trackablePose)
        {
            TrackableBehaviour trackableBehaviour;

            if (this.TryGetBehaviour(trackableId, out trackableBehaviour) && trackableBehaviour.enabled)
            {
                this.PositionCameraToTrackable(trackableBehaviour, cameraTransform, parentTransformToUpdate, trackablePose);
            }
        }
Ejemplo n.º 13
0
 private void CheckForHoloLensPoseUpdates(HoloLensExtendedTrackingManager.PoseAgeEntry poseEntry, TrackableBehaviour trackableBehaviour, VuforiaManager.TrackableIdPair trackableResultID, int trackableID, float minPoseUpdateDistance, float maxPoseDistance, Transform cameraTransform, out bool resetPoseInfo)
 {
     resetPoseInfo = true;
     if (this.IsTargetWellInView(trackableBehaviour, cameraTransform))
     {
         HoloLensExtendedTrackingManager.PoseInfo poseInfo = this.mTrackablesCurrentlyExtendedTracked[trackableResultID];
         float magnitude = (poseInfo.Position - trackableBehaviour.transform.position).magnitude;
         float num       = Quaternion.Angle(poseInfo.Rotation, trackableBehaviour.transform.rotation);
         if (this.CalculateTargetSizeInCameraViewCoeff(trackableBehaviour, cameraTransform.position) <= this.mTrackableSizeInViewThreshold)
         {
             poseInfo.NumFramesPoseWasOff = 0;
             this.mTrackablesCurrentlyExtendedTracked[trackableResultID] = poseInfo;
             if (magnitude > minPoseUpdateDistance || num > this.mMinPoseUpdateAngleDiff)
             {
                 this.CheckHandoverToHoloLens(poseEntry, trackableBehaviour, trackableResultID, maxPoseDistance, true, out resetPoseInfo);
                 return;
             }
         }
         else
         {
             if (magnitude > minPoseUpdateDistance || num > this.mMinPoseUpdateAngleDiff)
             {
                 poseInfo.NumFramesPoseWasOff++;
             }
             else
             {
                 poseInfo.NumFramesPoseWasOff = 0;
             }
             this.mTrackablesCurrentlyExtendedTracked[trackableResultID] = poseInfo;
             if (poseInfo.NumFramesPoseWasOff > this.mMinNumFramesPoseOff)
             {
                 this.ResetExtendedTrackingForTrackable(trackableID);
             }
         }
     }
 }
Ejemplo n.º 14
0
        private void CheckHandoverToHoloLens(HoloLensExtendedTrackingManager.PoseAgeEntry poseEntry, TrackableBehaviour trackableBehaviour, VuforiaManager.TrackableIdPair trackableResultID, float maxPoseDistance, bool isPoseUpdate, out bool resetPoseInfo)
        {
            IHoloLensApiAbstraction holoLensApiAbstraction = VuforiaUnity.GetHoloLensApiAbstraction();

            resetPoseInfo = true;
            float arg_4B_0 = (poseEntry.Pose.Position - trackableBehaviour.transform.position).magnitude;
            float num      = Quaternion.Angle(poseEntry.Pose.Rotation, trackableBehaviour.transform.rotation);

            if (arg_4B_0 <= maxPoseDistance && num <= this.mMaxPoseAngleDiff)
            {
                poseEntry.Age++;
                this.mTrackingList[trackableResultID] = poseEntry;
                resetPoseInfo = false;
                if (poseEntry.Age > this.mNumFramesStablePose)
                {
                    HoloLensExtendedTrackingManager.PoseInfo poseInfo = new HoloLensExtendedTrackingManager.PoseInfo
                    {
                        Position            = trackableBehaviour.transform.position,
                        Rotation            = trackableBehaviour.transform.rotation,
                        NumFramesPoseWasOff = 0
                    };
                    this.mTrackablesCurrentlyExtendedTracked[trackableResultID] = poseInfo;
                    if (isPoseUpdate)
                    {
                        holoLensApiAbstraction.DeleteWorldAnchor(trackableResultID);
                        trackableBehaviour.transform.position = poseInfo.Position;
                        trackableBehaviour.transform.rotation = poseInfo.Rotation;
                    }
                    if (this.mSetWorldAnchors)
                    {
                        holoLensApiAbstraction.SetWorldAnchor(trackableBehaviour, trackableResultID);
                    }
                    this.mExtendedTrackablesState[trackableResultID] = TrackableBehaviour.Status.EXTENDED_TRACKED;
                }
            }
        }