Exemple #1
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);
             }
         }
     }
 }
Exemple #2
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;
                }
            }
        }
Exemple #3
0
        public void ApplyTrackingState(TrackableBehaviour trackableBehaviour, TrackableBehaviour.Status vuforiaStatus, Transform cameraTransform)
        {
            ExtendedTrackable extendedTrackable = trackableBehaviour.Trackable as ExtendedTrackable;

            if (extendedTrackable == null)
            {
                return;
            }
            float expr_16               = extendedTrackable.GetLargestSizeComponent();
            float maxPoseDistance       = expr_16 * this.mMaxPoseRelDistance;
            float minPoseUpdateDistance = expr_16 * this.mMinPoseUpdateRelDistance;
            int   iD = trackableBehaviour.Trackable.ID;

            VuforiaManager.TrackableIdPair trackableIdPair;
            if (trackableBehaviour is VuMarkAbstractBehaviour)
            {
                trackableIdPair = VuforiaManager.TrackableIdPair.FromTrackableAndResultId(iD, ((VuMarkAbstractBehaviour)trackableBehaviour).VuMarkResultId);
            }
            else
            {
                trackableIdPair = VuforiaManager.TrackableIdPair.FromTrackableId(iD);
            }
            if (vuforiaStatus == TrackableBehaviour.Status.TRACKED && this.mTrackablesExtendedTrackingEnabled.Contains(iD))
            {
                bool flag = true;
                if (this.mTrackingList.ContainsKey(trackableIdPair))
                {
                    HoloLensExtendedTrackingManager.PoseAgeEntry poseAgeEntry = this.mTrackingList[trackableIdPair];
                    float arg_D3_0 = (poseAgeEntry.CameraPose.Position - cameraTransform.position).magnitude;
                    float num      = Quaternion.Angle(poseAgeEntry.CameraPose.Rotation, cameraTransform.rotation);
                    if (arg_D3_0 <= this.mMaxCamPoseAbsDistance && num <= this.mMaxCamPoseAngleDiff)
                    {
                        if (!this.mTrackablesCurrentlyExtendedTracked.ContainsKey(trackableIdPair))
                        {
                            this.CheckHandoverToHoloLens(poseAgeEntry, trackableBehaviour, trackableIdPair, maxPoseDistance, false, out flag);
                        }
                        else
                        {
                            this.CheckForHoloLensPoseUpdates(poseAgeEntry, trackableBehaviour, trackableIdPair, iD, minPoseUpdateDistance, maxPoseDistance, cameraTransform, out flag);
                        }
                    }
                }
                if (flag)
                {
                    this.mTrackingList[trackableIdPair] = new HoloLensExtendedTrackingManager.PoseAgeEntry
                    {
                        Pose = new HoloLensExtendedTrackingManager.PoseInfo
                        {
                            Position = trackableBehaviour.transform.position,
                            Rotation = trackableBehaviour.transform.rotation
                        },
                        CameraPose = new HoloLensExtendedTrackingManager.PoseInfo
                        {
                            Position = cameraTransform.position,
                            Rotation = cameraTransform.rotation
                        },
                        Age = 1
                    };
                }
            }
            if (this.mTrackablesCurrentlyExtendedTracked.ContainsKey(trackableIdPair))
            {
                if (!this.mSetWorldAnchors || VuforiaRuntimeUtilities.IsPlayMode())
                {
                    HoloLensExtendedTrackingManager.PoseInfo poseInfo = this.mTrackablesCurrentlyExtendedTracked[trackableIdPair];
                    trackableBehaviour.transform.position = poseInfo.Position;
                    trackableBehaviour.transform.rotation = poseInfo.Rotation;
                }
                vuforiaStatus = this.mExtendedTrackablesState[trackableIdPair];
            }
            trackableBehaviour.OnTrackerUpdate(vuforiaStatus);
        }