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);
         }
     }
 }
Exemplo n.º 3
0
 public void UpdateCamera(Transform cameraTransform, VuforiaManagerImpl.TrackableResultData[] trackableResultDataArray, int deviceTrackableID)
 {
     if (deviceTrackableID >= 0)
     {
         int i = 0;
         while (i < trackableResultDataArray.Length)
         {
             VuforiaManagerImpl.TrackableResultData trackableResultData = trackableResultDataArray[i];
             if (trackableResultData.id == deviceTrackableID)
             {
                 if (trackableResultData.status != TrackableBehaviour.Status.DETECTED && trackableResultData.status != TrackableBehaviour.Status.TRACKED && trackableResultData.status != TrackableBehaviour.Status.EXTENDED_TRACKED)
                 {
                     break;
                 }
                 if (this.mBeforeDevicePoseUpdated != null)
                 {
                     this.mBeforeDevicePoseUpdated.InvokeWithExceptionHandling();
                 }
                 this.PositionCamera(this.mDeviceTrackerPositonOffset, this.mDeviceTrackerRotationOffset, cameraTransform, trackableResultData.pose);
                 if (this.mAfterDevicePoseUpdated != null)
                 {
                     this.mAfterDevicePoseUpdated.InvokeWithExceptionHandling();
                     return;
                 }
                 break;
             }
             else
             {
                 i++;
             }
         }
     }
 }
 private void UnmarshalTrackables(VuforiaManagerImpl.FrameState frameState)
 {
     for (int i = 0; i < frameState.numTrackableResults; i++)
     {
         VuforiaManagerImpl.TrackableResultData trackableResultData = (VuforiaManagerImpl.TrackableResultData)Marshal.PtrToStructure(new IntPtr(frameState.trackableDataArray.ToInt64() + (long)(i * Marshal.SizeOf(typeof(VuforiaManagerImpl.TrackableResultData)))), typeof(VuforiaManagerImpl.TrackableResultData));
         this.mTrackableResultDataArray[i] = trackableResultData;
     }
     for (int j = 0; j < frameState.numPropTrackableResults; j++)
     {
         VuforiaManagerImpl.TrackableResultData trackableResultData2 = (VuforiaManagerImpl.TrackableResultData)Marshal.PtrToStructure(new IntPtr(frameState.propTrackableDataArray.ToInt64() + (long)(j * Marshal.SizeOf(typeof(VuforiaManagerImpl.TrackableResultData)))), typeof(VuforiaManagerImpl.TrackableResultData));
         this.mTrackableResultDataArray[frameState.numTrackableResults + j] = trackableResultData2;
     }
 }
Exemplo n.º 5
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);
                    }
                }
            }
        }
        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);
        }