Пример #1
0
    public void Load(string name, string filePath)
    {
        Debug.LogFormat("Loading ARWorldMap {0}", filePath);

        var worldMap = ARWorldMap.Load(filePath);

        if (worldMap != null)
        {
            GroundPlaneManager.instance.NewSession(true);

            m_LoadedMap = worldMap;
            Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);
            UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;

            var config = m_ARCameraManager.sessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            Debug.Log("Restarting session with worldMap");
            session.RunWithConfigAndOptions(config, runOption);

            loadingname = name;
            isLoading   = true;
        }
    }
Пример #2
0
        // Use this for initialization
        public override IEnumerator StartService(Settings settings)
        {
            m_SessionConfig = new ARKitWorldTrackingSessionConfiguration(
                UnityARAlignment.UnityARAlignmentGravity,
                settings.enablePlaneDetection ? UnityARPlaneDetection.Horizontal : UnityARPlaneDetection.None,
                settings.enablePointCloud,
                settings.enableLightEstimation);

            if (!IsSupported)
            {
                Debug.LogError("The requested ARKit session configuration is not supported");
                return(null);
            }

            UnityARSessionRunOption runOptions =
                UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
                UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            nativeInterface.RunWithConfigAndOptions(
                m_SessionConfig, runOptions);

            // Register for plane detection
            UnityARSessionNativeInterface.ARAnchorAddedEvent       += AddAnchor;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent     += UpdateAnchor;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent     += RemoveAnchor;
            UnityARSessionNativeInterface.ARFrameUpdatedEvent      += UpdateFrame;
            UnityARSessionNativeInterface.ARUserAnchorUpdatedEvent += UpdateUserAnchor;

            IsRunning = true;

            return(null);
        }
Пример #3
0
    public void Load(string fileName)
    {
        var worldMap = ARWorldMap.Load(Path.Combine(Application.persistentDataPath, string.Concat(fileName, ".worldmap")));

        if (worldMap != null)
        {
            windowManager.SpawnGuideToLoad();

            loadedWorldMapName = fileName;

            UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;
            relocalizing = true;
            startTime    = Time.time;

            ARKitWorldTrackingSessionConfiguration config = m_ARCameraManager.sessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            foreach (GameObject go in GameObject.FindGameObjectsWithTag("Line"))
            {
                Destroy(go);
            }

            session.RunWithConfigAndOptions(config, runOption);
        }
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;

        if (config.IsSupported)
        {
            m_session.RunWithConfig(config);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }

        UnityARSessionRunOption options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        m_session.RunWithConfigAndOptions(config, options);
    }
Пример #5
0
        void InitializeARKit(serializableARKitInit sai)
        {
            //#if !UNITY_EDITOR

            //get the config and runoption from editor and use them to initialize arkit on device
            Application.targetFrameRate = 60;
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitWorldTrackingSessionConfiguration config = sai.config;

            if (detectionImages != null)
            {
                config.arResourceGroupName = detectionImages.resourceGroupName;
            }

            UnityARSessionRunOption runOptions = sai.runOption;

            m_session.RunWithConfigAndOptions(config, runOptions);

            UnityARSessionNativeInterface.ARFrameUpdatedEvent += ARFrameUpdated;
            //UnityARSessionNativeInterface.ARAnchorAddedEvent += ARAnchorAdded;
            //UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated;
            //UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved;

            //#endif
        }
    /// <summary>
    /// Resumes the AR session, if paused.
    /// </summary>
    public override void ResumeSession()
    {
        if (isSessionPaused)
        {
            isSessionPaused = false;

            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.alignment      = cameraAlignment;
            config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical;

            config.getPointCloudData     = true;
            config.enableLightEstimation = true;
            config.enableAutoFocus       = true;

            if (arImageDatabase != null)
            {
                config.referenceImagesGroupName = arImageDatabase.resourceGroupName;
                Debug.Log("ResumeSession - config.arResourceGroupName set to: " + arImageDatabase.resourceGroupName);
            }

            UnityARSessionRunOption runOptions = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
                                                 UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, runOptions);
        }
    }
 public void RunWithConfigAndOptions(ARKitSessionConfiguration config, UnityARSessionRunOption runOptions)
 {
     config.alignment = UnityARAlignment.UnityARAlignmentGravityAndHeading;
     #if !UNITY_EDITOR
     StartSessionWithOptions(m_NativeARSession, config, runOptions);
     #endif
 }
Пример #8
0
    void LoadWorldMap()
    {
        Debug.Log("Attempting to load ARWorldMap.");

        //GlobalMapManager.Instance.DownloadLatestMap(() =>
        //{
        //    var worldMap = ARWorldMap.Load(GlobalMapManager.Instance.WorldMapPath);
        //    if (worldMap != null)
        //    {
        //        Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

        //        var config = ARKitManager.Instance.DefaultSessionConfiguration;
        //        config.worldMap = worldMap;
        //        UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        //        Debug.Log("Restarting session with worldMap");
        //        ARKitManager.Instance.Session.RunWithConfigAndOptions(config, runOption);
        //    }
        //});

        var worldMap = ARWorldMap.Load(GlobalMapManager.Instance.WorldMapPath);

        if (worldMap != null)
        {
            Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

            var config = ARKitManager.Instance.DefaultSessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            Debug.Log("Restarting session with worldMap");
            ARKitManager.Instance.Session.RunWithConfigAndOptions(config, runOption);
        }
    }
    // Use this for initialization
    void Start()
    {
        m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

#if !UNITY_EDITOR
        Application.targetFrameRate = 60;
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
        config.planeDetection        = planeDetection;
        config.alignment             = startAlignment;
        config.getPointCloudData     = getPointCloud;
        config.enableLightEstimation = enableLightEstimation;
        m_session.RunWithConfig(config);

        UnityARSessionRunOption options = new UnityARSessionRunOption();
        options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
        m_session.RunWithConfigAndOptions(config, options);

        if (m_camera == null)
        {
            m_camera = Camera.main;
        }
#else
        //put some defaults so that it doesnt complain
        UnityARCamera scamera = new UnityARCamera();
        scamera.worldTransform = new UnityARMatrix4x4(new Vector4(1, 0, 0, 0), new Vector4(0, 1, 0, 0), new Vector4(0, 0, 1, 0), new Vector4(0, 0, 0, 1));
        Matrix4x4 projMat = Matrix4x4.Perspective(60.0f, 1.33f, 0.1f, 30.0f);
        scamera.projectionMatrix = new UnityARMatrix4x4(projMat.GetColumn(0), projMat.GetColumn(1), projMat.GetColumn(2), projMat.GetColumn(3));

        UnityARSessionNativeInterface.SetStaticCamera(scamera);
#endif
    }
Пример #10
0
    public void Load()
    {
        if (path != null)
        {
            Debug.LogFormat("Loading ARWorldMap {0}", path);
            var worldMap = ARWorldMap.Load(path);
            if (worldMap != null)
            {
                m_LoadedMap = worldMap;
                Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

                UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;

                var config = m_ARCameraManager.sessionConfiguration;
                config.worldMap = worldMap;
                UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
                //m_TGOPlacement.Reset();
                //m_ESAPlacement.Reset();

                Debug.Log("Restarting session with worldMap");
                session.RunWithConfigAndOptions(config, runOption);
            }
        }
        else
        {
            Debug.Log("Please, specify a path");
        }
    }
        private void ConfigureSession(bool togglePlaneDetection, bool clearOldPlanes)
        {
            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();

            if (togglePlaneDetection)
            {
                if (UnityARSessionNativeInterface.IsARKit_1_5_Supported())
                {
                    config.planeDetection = UnityARPlaneDetection.HorizontalAndVertical;
                }
                else
                {
                    config.planeDetection = UnityARPlaneDetection.Horizontal;
                }
            }
            else
            {
                config.planeDetection = UnityARPlaneDetection.None;
            }

            if (clearOldPlanes)
            {
                mPlaneGenerator.ClearPlanes();
            }

            config.alignment             = UnityARAlignment.UnityARAlignmentGravity;
            config.getPointCloudData     = true;
            config.enableLightEstimation = true;

            UnityARSessionRunOption options = new UnityARSessionRunOption();

            //options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors;
            mSession.RunWithConfigAndOptions(config, options);
        }
Пример #12
0
        void InitializeARKit(serializableARKitInit sai)
        {
                        #if !UNITY_EDITOR
            //get the config and runoption from editor and use them to initialize arkit on device
            //added Sascha Gehlich's modifications to this method bc this seemed to help with the framerate issues
            Application.targetFrameRate = 60;
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitWorldTrackingSessionConfiguration config = sai.config;
            UnityARSessionRunOption runOptions            = sai.runOption;

            UnityARSessionNativeInterface session = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            config.planeDetection = UnityARPlaneDetection.Horizontal;
            var videoFormat = UnityARVideoFormat.SupportedVideoFormats()[UnityARVideoFormat.SupportedVideoFormats().Count - 1];
            config.videoFormat          = videoFormat.videoFormatPtr;
            Application.targetFrameRate = videoFormat.framesPerSecond;

            m_session.RunWithConfigAndOptions(config, runOptions);

            UnityARSessionNativeInterface.ARFrameUpdatedEvent  += ARFrameUpdated;
            UnityARSessionNativeInterface.ARAnchorAddedEvent   += ARAnchorAdded;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved;
                        #endif
        }
Пример #13
0
        public UniTask Load(string dirPath)
        {
            string     path     = GetPath(dirPath);
            ARWorldMap worldMap = ARWorldMap.Load(path);

            Debug.Log($"ARWorldMap loaded from {path}");

            ARKitWorldTrackingSessionConfiguration config = _camera.sessionConfiguration;

            config.worldMap = worldMap;

            const UnityARSessionRunOption runOption =
                UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors |
                UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            UnityARSessionNativeInterface
            .ARSessionShouldAttemptRelocalization = true;

            UnityARSessionNativeInterface
            .GetARSessionNativeInterface()
            .RunWithConfigAndOptions(config, runOption);

            Debug.Log("Restarted session with worldMap");

            return(UniTask.CompletedTask);
        }
        public void RunWithConfigAndOptions(ARKitFaceTrackingConfiguration config, UnityARSessionRunOption runOptions)
        {
#if !UNITY_EDITOR && UNITY_IOS
            StartFaceTrackingSessionWithOptions(m_NativeARSession, config, runOptions);
#elif UNITY_EDITOR
            CreateRemoteFaceTrackingConnection(config, runOptions);
#endif
        }
        public void RunWithConfigAndImage(ARKitWorldTrackingSessionConfiguration config, int a_BufferLength, byte[] a_ImageBuffer, float width)
        {
#if !UNITY_EDITOR
            StartWorldTrackingSessionWithImage(m_NativeARSession, config, a_BufferLength, a_ImageBuffer, width);
#else
            UnityARSessionRunOption runOptions = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            CreateRemoteWorldTrackingConnection(config, runOptions);
#endif
        }
        public void RunWithConfig(ARKitFaceTrackingConfiguration config)
        {
#if !UNITY_EDITOR && UNITY_IOS
            StartFaceTrackingSession(m_NativeARSession, config);
#elif UNITY_EDITOR
            UnityARSessionRunOption runOptions = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            CreateRemoteFaceTrackingConnection(config, runOptions);
#endif
        }
 public void RunWithConfig(ARKitWorldTrackingSessionConfiguration config)
 {
                 #if !UNITY_EDITOR
     StartWorldTrackingSession(m_NativeARSession, config);
                 #else
     UnityARSessionRunOption runOptions = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
     CreateRemoteWorldTrackingConnection(config, runOptions);
                 #endif
 }
Пример #18
0
    public void NewSession()
    {
        GroundPlaneManager.instance.NewSession(false);
        UnityARGeneratePlane.instance.NewSession();
        var config = m_ARCameraManager.sessionConfiguration;
        UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        session.RunWithConfigAndOptions(config, runOption);
    }
Пример #19
0
    private void OnLoadClick()
    {
        UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;//重定位

        ARWorldMap newWorldMap = ARWorldMap.Load(Config.path);
        ARKitWorldTrackingSessionConfiguration configration = m_ARCameraManager.sessionConfiguration;

        configration.worldMap = newWorldMap;
        UnityARSessionRunOption option = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        Config.m_Swssion.RunWithConfigAndOptions(configration, option);
    }
Пример #20
0
        void SendInitToPlayer()
        {
            serializableFromEditorMessage sfem = new serializableFromEditorMessage();

            sfem.subMessageId = SubMessageIds.editorInitARKit;
            serializableARSessionConfiguration ssc        = new serializableARSessionConfiguration(startAlignment, planeDetection, getPointCloud, enableLightEstimation, enableAutoFocus);
            UnityARSessionRunOption            roTracking = resetTracking ? UnityARSessionRunOption.ARSessionRunOptionResetTracking : 0;
            UnityARSessionRunOption            roAnchors  = removeExistingAnchors ? UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors : 0;

            sfem.arkitConfigMsg = new serializableARKitInit(ssc, roTracking | roAnchors);
            SendToPlayer(ConnectionMessageIds.fromEditorARKitSessionMsgId, sfem);
        }
Пример #21
0
    public void LoadBack()
    {
        ARKitWorldTrackingSessionConfiguration configuration = aRCameraManager.sessionConfiguration;
        UnityARSessionRunOption option = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(configuration, option);
        if (NetworkManager_custom)
        {
            NetworkManager_custom.M_Disconnect();
        }
        SceneManager.LoadScene("Labs/MainScene/Scene/MainScene");
    }
Пример #22
0
        private void InitializeARKit(serializableARKitInit sai)
        {
            Application.targetFrameRate = 60;
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitWorldTrackingSessionConfiguration config = sai.config;
            UnityARSessionRunOption runOption             = sai.runOption;

            m_session.RunWithConfigAndOptions(config, runOption);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent  += ARFrameUpdated;
            UnityARSessionNativeInterface.ARAnchorAddedEvent   += ARAnchorAdded;
            UnityARSessionNativeInterface.ARAnchorUpdatedEvent += ARAnchorUpdated;
            UnityARSessionNativeInterface.ARAnchorRemovedEvent += ARAnchorRemoved;
        }
        void SendInitToPlayer()
        {
            //we're going to reuse ARSessionConfiguration and only use its lightestimation field.
            serializableFromEditorMessage sfem = new serializableFromEditorMessage();

            sfem.subMessageId = SubMessageIds.editorInitARKitFaceTracking;
            serializableARSessionConfiguration ssc        = new serializableARSessionConfiguration(UnityARAlignment.UnityARAlignmentCamera, UnityARPlaneDetection.None, false, enableLightEstimation);
            UnityARSessionRunOption            roTracking = resetTracking ? UnityARSessionRunOption.ARSessionRunOptionResetTracking : 0;
            UnityARSessionRunOption            roAnchors  = removeExistingAnchors ? UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors : 0;

            sfem.arkitConfigMsg = new serializableARKitInit(ssc, roTracking | roAnchors);
            SendToPlayer(ConnectionMessageIds.fromEditorARKitSessionMsgId, sfem);
        }
Пример #24
0
    public void ResetAr()
    {
        sessionStarted = false;
        UnityARSessionRunOption options = new UnityARSessionRunOption();
        ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration(UnityARAlignment.UnityARAlignmentGravity, UnityARPlaneDetection.Horizontal);

        config  = setConfig(config);
        options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
        if (config.IsSupported)
        {
            m_session.RunWithConfigAndOptions(config, options);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent += FirstFrameUpdate;
        }
    }
Пример #25
0
    private void SendInitToPlayer()
    {
        serializableFromEditorMessage sfem = new serializableFromEditorMessage();

        sfem.subMessageId = SubMessageIds.editorInitARKitFaceTracking;
        serializableARSessionConfiguration ssc        = new serializableARSessionConfiguration(UnityARAlignment.UnityARAlignmentCamera, UnityARPlaneDetection.None, false, EnableLightEstimation, true);
        UnityARSessionRunOption            roTracking = ResetTracking ? UnityARSessionRunOption.ARSessionRunOptionResetTracking : 0;
        UnityARSessionRunOption            roAnchors  = RemoveExistingAnchors ? UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors : 0;

        sfem.arkitConfigMsg = new serializableARKitInit(ssc, roTracking | roAnchors);
        SendToPlayer(ConnectionMessageIds.fromEditorARKitSessionMsgId, sfem);
        SaveData(_timeCount, 0, null, true);
        _isStart = true;
    }
Пример #26
0
        void InitializeARKitFaceTracking(serializableARKitInit sai)
        {
#if !UNITY_EDITOR
            //get the config and runoption from editor and use them to initialize arkit for facetracking on device
            Application.targetFrameRate = 60;
            m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
            ARKitFaceTrackingConfiguration config     = sai.config;
            UnityARSessionRunOption        runOptions = sai.runOption;
            m_session.RunWithConfigAndOptions(config, runOptions);
            UnityARSessionNativeInterface.ARFrameUpdatedEvent      += ARFrameUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorAddedEvent   += ARFaceAnchorAdded;
            UnityARSessionNativeInterface.ARFaceAnchorUpdatedEvent += ARFaceAnchorUpdated;
            UnityARSessionNativeInterface.ARFaceAnchorRemovedEvent += ARFaceAnchorRemoved;
#endif
        }
Пример #27
0
            private void Start()
            {
#if UNITY_EDITOR
                // Disable AR in editor
                if (Camera.main != null)
                {
                    Camera.main.clearFlags = CameraClearFlags.Color;
                    UnityARVideo arVideo = Camera.main.GetComponent <UnityARVideo>();
                    if (arVideo != null)
                    {
                        arVideo.enabled = false;
                    }
                    Transform parent = Camera.main.transform.parent;
                    if (parent != null)
                    {
                        UnityARCameraManager arCameraManager = parent.GetComponentInChildren <UnityARCameraManager>();
                        if (arCameraManager != null)
                        {
                            arCameraManager.enabled = false;
                        }
                    }
                }
                AR3DOFCameraManager ar3dof = GetComponent <AR3DOFCameraManager>();
                if (ar3dof != null)
                {
                    ar3dof.enabled = false;
                }
#endif
                // Initialize the game object we'll use to
                // represent plane anchors
                if (planePrefab != null)
                {
                    UnityARUtility.InitializePlanePrefab(planePrefab);
                }

                // Initialize the anchor manager
                mUnityARAnchorManager = new UnityARAnchorManager();

                // Start the AR kit session
                ARKitWorldTackingSessionConfiguration sessionConfig = new ARKitWorldTackingSessionConfiguration(
                    UnityARAlignment.UnityARAlignmentCamera,
                    UnityARPlaneDetection.Horizontal
                    );
                sessionConfig.enableLightEstimation = true;
                UnityARSessionRunOption sessionRunOptions = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
                UnityARSessionNativeInterface.GetARSessionNativeInterface().Pause();                 // Stops current run
                UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(sessionConfig, sessionRunOptions);
            }
Пример #28
0
    void LoadSerializedWorldMap(byte[] worldMapInBytes)
    {
        ARWorldMap worldMap = ARWorldMap.SerializeFromByteArray(worldMapInBytes);

        Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

        UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;

        var config = m_ARCameraManager.sessionConfiguration;

        config.worldMap = worldMap;
        UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

        Debug.Log("Restarting session with worldMap");
        session.RunWithConfigAndOptions(config, runOption);
    }
Пример #29
0
    void RestartARSessionWith(ARWorldMap worldMap)
    {
        if (worldMap != null)
        {
            Debug.LogFormat("Map loaded. Center: {0} Extent: {1}", worldMap.center, worldMap.extent);

            UnityARSessionNativeInterface.ARSessionShouldAttemptRelocalization = true;

            var config = arCameraManager.sessionConfiguration;
            config.worldMap = worldMap;
            UnityARSessionRunOption runOption = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;

            Debug.Log("Restarting session with worldMap");
            UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, runOption);
        }
    }
Пример #30
0
        private void Start()
        {
#if UNITY_IOS
            // Ensure that ARkit reset the tracking when the scene gets restarted
            UnityARCameraManager    arkitCameraManager = FindObjectOfType <UnityARCameraManager>();
            UnityARSessionRunOption options            = new UnityARSessionRunOption();
            options = UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking;
            UnityARSessionNativeInterface nativeInterface = UnityARSessionNativeInterface.GetARSessionNativeInterface();

            ARKitWorldTrackingSessionConfiguration config = new ARKitWorldTrackingSessionConfiguration();
            config.planeDetection        = arkitCameraManager.planeDetection;
            config.alignment             = arkitCameraManager.startAlignment;
            config.getPointCloudData     = arkitCameraManager.getPointCloud;
            config.enableLightEstimation = arkitCameraManager.enableLightEstimation;
            nativeInterface.RunWithConfigAndOptions(config, options);
#endif
        }