public virtual bool Reset()
        {
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null && tracker.IsActive)
            {
                Debug.LogError("Tracker should be stopped prior to calling Reset()");
                return(false);
            }
            bool flag = VuforiaWrapper.Instance.ReconstructionReset(this.mNativeReconstructionPtr) == 1;

            if (flag)
            {
                SmartTerrainTracker tracker2 = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();
                if (tracker2 != null)
                {
                    foreach (ReconstructionAbstractBehaviour current in tracker2.SmartTerrainBuilder.GetReconstructions())
                    {
                        if (current.Reconstruction == this)
                        {
                            current.ClearOnReset();
                        }
                    }
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
        public override void OnTrackerUpdate(TrackableBehaviour.Status newStatus)
        {
            TrackableBehaviour.Status arg_06_0 = this.mStatus;
            bool flag = false;

            if (this.mInitializeSmartTerrain && this.mReconstructionToInitialize != null && (newStatus == TrackableBehaviour.Status.DETECTED || newStatus == TrackableBehaviour.Status.TRACKED))
            {
                flag = true;
            }
            base.OnTrackerUpdate(newStatus);
            if (flag && this.mReconstructionToInitialize != null)
            {
                ReconstructionFromTargetImpl reconstructionFromTargetImpl = (ReconstructionFromTargetImpl)this.mReconstructionToInitialize.ReconstructionFromTarget;
                if (reconstructionFromTargetImpl != null && reconstructionFromTargetImpl.CanAutoSetInitializationTarget && this.mTrackable != null)
                {
                    Vector3 vector;
                    Vector3 vector2;
                    if (reconstructionFromTargetImpl.GetInitializationTarget(out vector, out vector2) != this.mTrackable)
                    {
                        this.SetAsSmartTerrainInitializationTarget();
                        return;
                    }
                    SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();
                    if (tracker != null && this.mReconstructionToInitialize.ReconstructionBehaviour.AutomaticStart)
                    {
                        if (tracker.SmartTerrainBuilder.GetReconstructions().Contains(this.mReconstructionToInitialize.ReconstructionBehaviour))
                        {
                            reconstructionFromTargetImpl.Start();
                            return;
                        }
                        tracker.SmartTerrainBuilder.AddReconstruction(this.mReconstructionToInitialize.ReconstructionBehaviour);
                    }
                }
            }
        }
        private void UpdateSmartTerrain(VuforiaManagerImpl.FrameState frameState, StateManagerImpl stateManager)
        {
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null && tracker.SmartTerrainBuilder.GetReconstructions().Any <ReconstructionAbstractBehaviour>())
            {
                VuforiaManagerImpl.SmartTerrainRevisionData[] array = new VuforiaManagerImpl.SmartTerrainRevisionData[frameState.numSmartTerrainRevisions];
                VuforiaManagerImpl.SurfaceData[] array2             = new VuforiaManagerImpl.SurfaceData[frameState.numUpdatedSurfaces];
                VuforiaManagerImpl.PropData[]    array3             = new VuforiaManagerImpl.PropData[frameState.numUpdatedProps];
                for (int i = 0; i < frameState.numSmartTerrainRevisions; i++)
                {
                    VuforiaManagerImpl.SmartTerrainRevisionData smartTerrainRevisionData = (VuforiaManagerImpl.SmartTerrainRevisionData)Marshal.PtrToStructure(new IntPtr(frameState.smartTerrainRevisionsArray.ToInt64() + (long)(i * Marshal.SizeOf(typeof(VuforiaManagerImpl.SmartTerrainRevisionData)))), typeof(VuforiaManagerImpl.SmartTerrainRevisionData));
                    array[i] = smartTerrainRevisionData;
                }
                for (int j = 0; j < frameState.numUpdatedSurfaces; j++)
                {
                    VuforiaManagerImpl.SurfaceData surfaceData = (VuforiaManagerImpl.SurfaceData)Marshal.PtrToStructure(new IntPtr(frameState.updatedSurfacesArray.ToInt64() + (long)(j * Marshal.SizeOf(typeof(VuforiaManagerImpl.SurfaceData)))), typeof(VuforiaManagerImpl.SurfaceData));
                    array2[j] = surfaceData;
                }
                for (int k = 0; k < frameState.numUpdatedProps; k++)
                {
                    VuforiaManagerImpl.PropData propData = (VuforiaManagerImpl.PropData)Marshal.PtrToStructure(new IntPtr(frameState.updatedPropsArray.ToInt64() + (long)(k * Marshal.SizeOf(typeof(VuforiaManagerImpl.PropData)))), typeof(VuforiaManagerImpl.PropData));
                    array3[k] = propData;
                }
                ((SmartTerrainBuilderImpl)tracker.SmartTerrainBuilder).UpdateSmartTerrainData(array, array2, array3);
            }
        }
        public override T InitTracker <T>()
        {
            if (!VuforiaRuntimeUtilities.IsVuforiaEnabled())
            {
                return(default(T));
            }
            bool flag = true;

            if (VuforiaRuntimeUtilities.IsPlayMode() && (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker)))
            {
                flag = false;
            }
            if (flag && VuforiaWrapper.Instance.TrackerManagerInitTracker((int)TypeMapping.GetTypeID(typeof(T))) == 0)
            {
                Debug.LogError("Could not initialize the tracker.");
                return(default(T));
            }
            if (typeof(T) == typeof(ObjectTracker))
            {
                if (this.mObjectTracker == null)
                {
                    this.mObjectTracker = new ObjectTrackerImpl();
                }
                return(this.mObjectTracker as T);
            }
            if (typeof(T) == typeof(TextTracker))
            {
                if (this.mTextTracker == null)
                {
                    this.mTextTracker = new TextTrackerImpl();
                }
                return(this.mTextTracker as T);
            }
            if (typeof(T) == typeof(SmartTerrainTracker))
            {
                if (this.mSmartTerrainTracker == null)
                {
                    this.mSmartTerrainTracker = new SmartTerrainTrackerImpl();
                }
                return(this.mSmartTerrainTracker as T);
            }
            if (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker))
            {
                if (this.mDeviceTracker == null)
                {
                    if (VuforiaRuntimeUtilities.IsPlayMode())
                    {
                        this.mDeviceTracker = new RotationalPlayModeDeviceTrackerImpl();
                    }
                    else
                    {
                        this.mDeviceTracker = new RotationalDeviceTrackerImpl();
                    }
                }
                return(this.mDeviceTracker as T);
            }
            Debug.LogError("Could not initialize tracker. Unknown tracker type.");
            return(default(T));
        }
Ejemplo n.º 5
0
        internal static bool StopCameraIfPossible(out bool objectTrackerWasStopped)
        {
            bool flag  = false;
            bool flag2 = false;

            if (CameraDevice.Instance.IsActive())
            {
                SmartTerrainTracker tracker  = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();
                TextTracker         tracker2 = TrackerManager.Instance.GetTracker <TextTracker>();
                if ((tracker == null || !tracker.IsActive) && (tracker2 == null || !tracker2.IsActive))
                {
                    bool          flag3    = false;
                    ObjectTracker tracker3 = TrackerManager.Instance.GetTracker <ObjectTracker>();
                    if (tracker3 != null && tracker3.IsActive)
                    {
                        if (tracker3.GetActiveDataSets().Any <DataSet>())
                        {
                            flag3 = true;
                        }
                        else
                        {
                            TargetFinder.InitState initState = tracker3.TargetFinder.GetInitState();
                            if (initState == TargetFinder.InitState.INIT_RUNNING || initState == TargetFinder.InitState.INIT_SUCCESS)
                            {
                                flag3 = true;
                            }
                            else if (tracker3.TargetFinder.GetImageTargets().Any <ImageTarget>())
                            {
                                flag3 = true;
                            }
                            else if (tracker3.ImageTargetBuilder.IsScanning())
                            {
                                flag3 = true;
                            }
                            else
                            {
                                flag2 = true;
                            }
                        }
                    }
                    if (!flag3)
                    {
                        flag = true;
                    }
                }
            }
            if (flag2)
            {
                TrackerManager.Instance.GetTracker <ObjectTracker>().Stop();
            }
            if (flag)
            {
                CameraDevice.Instance.Stop();
            }
            objectTrackerWasStopped = flag2;
            return(flag);
        }
        private void StopSmartTerrainTracker()
        {
            Debug.Log("Stopping Smart Terrain Tracker");
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null)
            {
                tracker.Stop();
            }
        }
        public void RegisterTrackerStartedCallback(Action callback)
        {
            this.mTrackerStarted = (Action)Delegate.Combine(this.mTrackerStarted, callback);
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null && tracker.IsActive)
            {
                callback();
            }
        }
Ejemplo n.º 8
0
 private void OnTrackerStarted()
 {
     if (this.mReconstructionFromTarget == null)
     {
         SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();
         if (tracker != null)
         {
             this.mReconstructionFromTarget = tracker.SmartTerrainBuilder.CreateReconstruction <ReconstructionFromTarget>();
         }
     }
 }
 private void InitSmartTerrainTracker()
 {
     if (TrackerManager.Instance.GetTracker <SmartTerrainTracker>() == null)
     {
         SmartTerrainTracker smartTerrainTracker = TrackerManager.Instance.InitTracker <SmartTerrainTracker>();
         smartTerrainTracker.SetScaleToMillimeter(this.mSceneUnitsToMillimeter);
         if (this.mAutoInitBuilder)
         {
             smartTerrainTracker.SmartTerrainBuilder.Init();
         }
     }
 }
        protected override void OnDestroy()
        {
            ((StateManagerImpl)TrackerManager.Instance.GetStateManager()).ClearTrackableBehaviours();
            ObjectTracker tracker = TrackerManager.Instance.GetTracker <ObjectTracker>();

            if (tracker != null)
            {
                tracker.DestroyAllDataSets(false);
                tracker.Stop();
            }
            TextTracker tracker2 = TrackerManager.Instance.GetTracker <TextTracker>();

            if (tracker2 != null)
            {
                tracker2.Stop();
            }
            SmartTerrainTracker tracker3 = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker3 != null)
            {
                tracker3.Stop();
            }
            DeviceTracker tracker4 = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker4 != null)
            {
                tracker4.Stop();
            }
            VuforiaManager.Instance.Deinit();
            if (tracker != null)
            {
                TrackerManager.Instance.DeinitTracker <ObjectTracker>();
            }
            if (tracker2 != null)
            {
                TrackerManager.Instance.DeinitTracker <TextTracker>();
            }
            if (tracker3 != null)
            {
                tracker3.SmartTerrainBuilder.Deinit();
                TrackerManager.Instance.DeinitTracker <SmartTerrainTracker>();
            }
            if (tracker4 != null)
            {
                TrackerManager.Instance.DeinitTracker <DeviceTracker>();
            }
            this.mHasStartedOnce = false;
            if (this.mOnVuforiaDeinitialized != null)
            {
                this.mOnVuforiaDeinitialized.InvokeWithExceptionHandling();
            }
        }
        protected override void OnDisable()
        {
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null)
            {
                this.mTrackerWasActiveBeforeDisabling = tracker.IsActive;
                if (tracker.IsActive)
                {
                    this.StopSmartTerrainTracker();
                }
            }
        }
        private void StartSmartTerrainTracker()
        {
            Debug.Log("Starting Smart Terrain Tracker");
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null)
            {
                tracker.Start();
                if (this.mTrackerStarted != null)
                {
                    this.mTrackerStarted.InvokeWithExceptionHandling();
                }
            }
        }
Ejemplo n.º 13
0
 internal void Initialize(Reconstruction reconstruction)
 {
     this.mReconstruction = reconstruction;
     if (TrackerManager.Instance.GetTracker <SmartTerrainTracker>() != null)
     {
         if (this.mMaximumExtentEnabled)
         {
             this.mReconstruction.SetMaximumArea(this.mMaximumExtent);
         }
         if (this.mAutomaticStart)
         {
             SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();
             if (tracker != null)
             {
                 tracker.SmartTerrainBuilder.AddReconstruction(this);
             }
         }
         if (this.mNavMeshUpdates)
         {
             this.mReconstruction.StartNavMeshUpdates();
             this.mReconstruction.SetNavMeshPadding(this.mNavMeshPadding);
         }
         else
         {
             this.mReconstruction.StopNavMeshUpdates();
         }
         this.mHasInitialized = true;
         using (List <ISmartTerrainEventHandler> .Enumerator enumerator = this.mSmartTerrainEventHandlers.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 enumerator.Current.OnInitialized(default(SmartTerrainInitializationInfo));
             }
         }
         if (this.mOnInitialized != null)
         {
             this.mOnInitialized.InvokeWithExceptionHandling(default(SmartTerrainInitializationInfo));
             return;
         }
     }
     else
     {
         Debug.LogError("SmartTerrainTrackerBehaviour.Initialize: SmartTerrainTracker is null, aborting.");
     }
 }
        public virtual bool Start()
        {
            bool flag = false;
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null && tracker.IsActive)
            {
                tracker.Stop();
                flag = true;
            }
            bool arg_3D_0 = VuforiaWrapper.Instance.ReconstructionStart(this.mNativeReconstructionPtr) == 1;

            if (flag)
            {
                tracker.Start();
            }
            return(arg_3D_0);
        }
Ejemplo n.º 15
0
 private void OnDestroy()
 {
     if (this.mReconstructionBehaviour != null)
     {
         SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();
         if (tracker != null)
         {
             if (tracker.SmartTerrainBuilder.GetReconstructions().Contains(this.mReconstructionBehaviour))
             {
                 tracker.SmartTerrainBuilder.RemoveReconstruction(this.mReconstructionBehaviour);
             }
             if (this.mReconstructionBehaviour.Reconstruction != null)
             {
                 tracker.SmartTerrainBuilder.DestroyReconstruction(this.mReconstructionFromTarget);
             }
         }
         this.mReconstructionBehaviour.Deinitialize();
     }
     SmartTerrainTrackerARController.Instance.UnregisterTrackerStartedCallback(new Action(this.OnTrackerStarted));
 }
        internal void OnPause(bool pause)
        {
            SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker != null)
            {
                if (pause)
                {
                    this.mTrackerWasActiveBeforePause = tracker.IsActive;
                    if (tracker.IsActive)
                    {
                        this.StopSmartTerrainTracker();
                        return;
                    }
                }
                else if (this.mTrackerWasActiveBeforePause)
                {
                    this.StartSmartTerrainTracker();
                }
            }
        }
 private void DeinitRequestedTrackers()
 {
     if (this.mTrackersRequestedToDeinit.Count > 0)
     {
         base.VuforiaBehaviour.enabled = false;
         foreach (Type current in this.mTrackersRequestedToDeinit)
         {
             if (current == typeof(ObjectTracker))
             {
                 TrackerManager.Instance.DeinitTracker <ObjectTracker>();
             }
             else if (current == typeof(TextTracker))
             {
                 TrackerManager.Instance.DeinitTracker <TextTracker>();
             }
             else if (current == typeof(SmartTerrainTracker))
             {
                 SmartTerrainTracker tracker = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();
                 if (tracker != null)
                 {
                     tracker.SmartTerrainBuilder.Deinit();
                     TrackerManager.Instance.DeinitTracker <SmartTerrainTracker>();
                 }
             }
             else if (current == typeof(DeviceTracker))
             {
                 TrackerManager.Instance.DeinitTracker <DeviceTracker>();
             }
             else
             {
                 Debug.LogError("Could not deinitialize tracker. Unknown tracker type.");
             }
         }
         base.VuforiaBehaviour.enabled = true;
         this.mTrackersRequestedToDeinit.Clear();
     }
 }
        public override bool DeinitTracker <T>()
        {
            bool flag = true;

            if (VuforiaRuntimeUtilities.IsPlayMode() && (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker)))
            {
                flag = false;
            }
            if (flag && VuforiaWrapper.Instance.TrackerManagerDeinitTracker((int)TypeMapping.GetTypeID(typeof(T))) == 0)
            {
                Debug.LogError("Could not deinitialize the tracker.");
                return(false);
            }
            if (typeof(T) == typeof(ObjectTracker))
            {
                this.mObjectTracker = null;
            }
            else if (typeof(T) == typeof(TextTracker))
            {
                this.mTextTracker = null;
            }
            else if (typeof(T) == typeof(SmartTerrainTracker))
            {
                this.mSmartTerrainTracker = null;
            }
            else
            {
                if (typeof(T) != typeof(DeviceTracker) && typeof(T) != typeof(RotationalDeviceTracker))
                {
                    Debug.LogError("Could not deinitialize tracker. Unknown tracker type.");
                    return(false);
                }
                this.mDeviceTracker = null;
            }
            return(true);
        }