Пример #1
0
        public void CreateSession(NRSessionBehaviour session)
        {
            if (IsInitialized || session == null)
            {
                return;
            }
            if (NRSessionBehaviour != null)
            {
                NRDebugger.LogError("Multiple SessionBehaviour components cannot exist in the scene. " +
                                    "Destroying the newest.");
                GameObject.DestroyImmediate(session.gameObject);
                return;
            }
            NRDevice.Instance.Init();
            NativeAPI = new NativeInterface();
#if !UNITY_EDITOR_OSX
            NativeAPI.NativeTracking.Create();
#endif
            NRSessionBehaviour = session;

            NRHMDPoseTracker = session.GetComponent <NRHMDPoseTracker>();
            TrackingMode mode = NRHMDPoseTracker.TrackingMode == TrackingType.Tracking3Dof ? TrackingMode.MODE_3DOF : TrackingMode.MODE_6DOF;
            SetTrackingMode(mode);

            this.DeployData();

            NRKernalUpdater.Instance.OnUpdate += NRFrame.OnUpdate;
        }
Пример #2
0
        public void CreateSession(NRSessionBehaviour session)
        {
            if (SessionState != SessionState.UnInitialized && SessionState != SessionState.Destroyed)
            {
                return;
            }

            if (NRSessionBehaviour != null)
            {
                NRDebugger.LogError("Multiple SessionBehaviour components cannot exist in the scene. " +
                                    "Destroying the newest.");
                GameObject.DestroyImmediate(session.gameObject);
                return;
            }
            NRSessionBehaviour = session;
            NRHMDPoseTracker   = session.GetComponent <NRHMDPoseTracker>();

            try
            {
                NRDevice.Instance.Init();
            }
            catch (Exception)
            {
                throw;
            }

            NativeAPI = new NativeInterface();
            AsyncTaskExecuter.Instance.RunAction(() =>
            {
                NRDebugger.Log("AsyncTaskExecuter: Create tracking");
                switch (NRHMDPoseTracker.TrackingMode)
                {
                case NRHMDPoseTracker.TrackingType.Tracking6Dof:
                    NativeAPI.NativeTracking.Create();
                    NativeAPI.NativeTracking.SetTrackingMode(TrackingMode.MODE_6DOF);
                    break;

                case NRHMDPoseTracker.TrackingType.Tracking3Dof:
                    NativeAPI.NativeTracking.Create();
                    NRSessionBehaviour.SessionConfig.PlaneFindingMode  = TrackablePlaneFindingMode.DISABLE;
                    NRSessionBehaviour.SessionConfig.ImageTrackingMode = TrackableImageFindingMode.DISABLE;
                    NativeAPI.NativeTracking.SetTrackingMode(TrackingMode.MODE_3DOF);
                    break;

                default:
                    break;
                }
            });

            NRKernalUpdater.Instance.OnUpdate -= Update;
            NRKernalUpdater.Instance.OnUpdate += Update;

            SessionState = SessionState.Initialized;

            LoadNotification();
        }
Пример #3
0
        public void CreateSession(NRSessionBehaviour session)
        {
            if (SessionState != SessionState.UnInitialized && SessionState != SessionState.Destroyed)
            {
                return;
            }
            if (NRSessionBehaviour != null)
            {
                NRDebugger.LogError("Multiple SessionBehaviour components cannot exist in the scene. " +
                                    "Destroying the newest.");
                GameObject.DestroyImmediate(session.gameObject);
                return;
            }
            NRSessionBehaviour = session;
            NRHMDPoseTracker   = session.GetComponent <NRHMDPoseTracker>();

            try
            {
                NRDevice.Instance.Init();
                NRDevice.Instance.CreateGlassesController();
                NRDevice.Instance.CreateHMD();
            }
            catch (Exception)
            {
                throw;
            }

            NativeAPI = new NativeInterface();
            NativeAPI.NativeTracking.Create();
            bool         is3dof = (NRHMDPoseTracker.TrackingMode == NRHMDPoseTracker.TrackingType.Tracking3Dof);
            TrackingMode mode   = is3dof ? TrackingMode.MODE_3DOF : TrackingMode.MODE_6DOF;

            if (mode == TrackingMode.MODE_3DOF)
            {
                NRSessionBehaviour.SessionConfig.PlaneFindingMode  = TrackablePlaneFindingMode.DISABLE;
                NRSessionBehaviour.SessionConfig.ImageTrackingMode = TrackableImageFindingMode.DISABLE;
            }
            NativeAPI.NativeTracking.SetTrackingMode(mode);

            NRKernalUpdater.Instance.OnUpdate -= Update;
            NRKernalUpdater.Instance.OnUpdate += Update;

            SessionState = SessionState.Initialized;
        }
Пример #4
0
        public void CreateSession(NRSessionBehaviour session)
        {
            if (SessionBehaviour != null)
            {
                NRDebug.LogError("Multiple SessionBehaviour components cannot exist in the scene. " +
                                 "Destroying the newest.");
                GameObject.Destroy(session);
                return;
            }
            NativeAPI        = new NativeInterface();
            SessionStatus    = NativeAPI.NativeTracking.Create() ? SessionState.Created : SessionState.UnInitialize;
            SessionBehaviour = session;

            NRHMDPoseTracker = session.GetComponent <NRHMDPoseTracker>();
            TrackingMode mode = NRHMDPoseTracker.TrackingMode == TrackingType.Tracking3Dof ? TrackingMode.MODE_3DOF : TrackingMode.MODE_6DOF;

            SetTrackingMode(mode);

            this.DeployData();
        }