示例#1
0
        private void Update()
        {
            if (Trackable == null)
            {
                NRDebug.LogError("NRAnchor components instantiated outside of NRInternel are not supported. " +
                                 "Please use a 'Create' method within NRInternel to instantiate anchors.");
                return;
            }

            if (IsSessionDestroyed())
            {
                return;
            }

            var pose = Trackable.GetCenterPose();

            transform.position = pose.position;
            transform.rotation = pose.rotation;
        }
示例#2
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();
        }
示例#3
0
        public void UpdateConfig(NRSessionConfig config)
        {
            if (m_ConfigHandle == 0)
            {
                m_ConfigHandle = this.Create();
            }

            if (m_ConfigHandle == 0)
            {
                NRDebug.LogError("Faild to Create ARSessionConfig!!!");
                return;
            }

            var plane_find_mode = this.GetPlaneFindMode(m_ConfigHandle);

            if (plane_find_mode != config.PlaneFindingMode)
            {
                SetPlaneFindMode(m_ConfigHandle, config.PlaneFindingMode);
            }

            if (config.ImageTrackingMode != m_ImageTrackingMode)
            {
                //Trackable Image
                switch (config.ImageTrackingMode)
                {
                case TrackableImageFindingMode.DISABLE:
                    if (m_DatabaseHandle != 0)
                    {
                        m_NativeTrackableImage.DestroyDataBase(m_DatabaseHandle);
                        m_DatabaseHandle = 0;
                    }
                    else
                    {
                        var result = SetTrackableImageDataBase(m_ConfigHandle, 0);
                        NRDebug.Log("[Disable trackable image] result : " + result);
                    }
                    break;

                case TrackableImageFindingMode.ENABLE:
                    if (m_DatabaseHandle == 0)
                    {
                        if (config.TrackingImageDatabase != null)
                        {
                            m_DatabaseHandle = m_NativeTrackableImage.CreateDataBase();
                            bool result = m_NativeTrackableImage.LoadDataBase(m_DatabaseHandle, config.TrackingImageDatabase.TrackingImageDataPath);
                            NRDebug.Log("[LoadDataBase] result : " + result);
                            result = SetTrackableImageDataBase(m_ConfigHandle, m_DatabaseHandle);
                            NRDebug.Log("[SetTrackableImageDataBase] result : " + result);
                        }
                        else
                        {
                            var result = SetTrackableImageDataBase(m_ConfigHandle, 0);
                            NRDebug.Log("[Disable trackable image] result : " + result);
                        }
                    }
                    break;

                default:
                    break;
                }

                m_ImageTrackingMode = config.ImageTrackingMode;
            }
        }