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); } } }
internal void UpdateVuMarks(VuforiaManagerImpl.VuMarkTargetData[] newVuMarks, VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResults) { this.UpdateNewVuMarks(newVuMarks); HashSet <int> hashSet = new HashSet <int>(); for (int i = 0; i < vuMarkResults.Length; i++) { VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = vuMarkResults[i]; hashSet.Add(vuMarkTargetResultData.targetID); } this.UpdateLostVuMarks(hashSet); this.UpdateVuMarkResults(vuMarkResults); }
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); } } } }
private void UpdateVuMarkResults(VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResults) { HashSet <int> hashSet = new HashSet <int>(); VuforiaManagerImpl.VuMarkTargetResultData[] array = vuMarkResults; for (int i = 0; i < array.Length; i++) { VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = array[i]; hashSet.Add(vuMarkTargetResultData.resultID); } foreach (VuMarkAbstractBehaviour current in this.GetActiveBehaviours().ToList <VuMarkAbstractBehaviour>()) { if (!hashSet.Contains(current.VuMarkResultId)) { this.MarkBehaviourUntracked(current); } } array = vuMarkResults; for (int i = 0; i < array.Length; i++) { VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData2 = array[i]; VuMarkTarget vuMarkTarget = this.GetVuMarkTarget(vuMarkTargetResultData2.targetID); if (vuMarkTarget == null) { Debug.LogError("Error: Target is not available"); } VuMarkAbstractBehaviour vuMarkAbstractBehaviour = null; foreach (VuMarkAbstractBehaviour current2 in this.GetActiveBehaviours(vuMarkTarget).ToList <VuMarkAbstractBehaviour>()) { if (current2.VuMarkResultId == vuMarkTargetResultData2.resultID) { vuMarkAbstractBehaviour = current2; break; } } if (vuMarkAbstractBehaviour == null) { VuMarkAbstractBehaviour vuMarkAbstractBehaviour2 = this.CreateOrGetUnusedBehaviour(vuMarkTarget.Template.ID); this.AssociateTargetWithBehaviour(vuMarkTarget, vuMarkAbstractBehaviour2); vuMarkAbstractBehaviour = vuMarkAbstractBehaviour2; vuMarkAbstractBehaviour.VuMarkResultId = vuMarkTargetResultData2.resultID; } } }
internal void UpdateVuMarkPoses(Transform arCameraTransform, VuforiaManagerImpl.VuMarkTargetResultData[] vuMarkResults, int originTrackableResultId) { for (int i = 0; i < vuMarkResults.Length; i++) { VuforiaManagerImpl.VuMarkTargetResultData vuMarkTargetResultData = vuMarkResults[i]; VuMarkAbstractBehaviour activeBehaviour = this.GetActiveBehaviour(vuMarkTargetResultData.targetID, vuMarkTargetResultData.resultID); if (activeBehaviour != null) { if (vuMarkTargetResultData.resultID != originTrackableResultId) { StateManagerImpl.PositionTrackable(activeBehaviour, arCameraTransform, vuMarkTargetResultData.pose, vuMarkTargetResultData.timeStamp); } } else { Debug.Log(string.Format("Have a null behaviour while iterating over VuMarkResults: resultID={0}, targetID={1}", vuMarkTargetResultData.targetID, vuMarkTargetResultData.resultID)); } } }