Example #1
0
 /// <summary>
 /// ValueType copy from another SessionConfig object into this one.
 /// </summary>
 /// <param name="other"></param>
 public void CopyFrom(NRSessionConfig other)
 {
     OptimizedRendering    = other.OptimizedRendering;
     PlaneFindingMode      = other.PlaneFindingMode;
     ImageTrackingMode     = other.ImageTrackingMode;
     TrackingImageDatabase = other.TrackingImageDatabase;
 }
Example #2
0
        public async Task <bool> UpdateConfig(NRSessionConfig config)
        {
            if (m_IsUpdateConfigLock)
            {
                return(false);
            }
            m_IsUpdateConfigLock = true;
            if (m_ConfigHandle == 0)
            {
                m_ConfigHandle = this.Create();
            }

            if (m_ConfigHandle == 0 || m_LastSessionConfig.Equals(config))
            {
                NRDebugger.Log("[NativeConfigration] Faild to Update NRSessionConfig!!!");
                m_IsUpdateConfigLock = false;
                return(false);
            }

            await UpdatePlaneFindMode(config);
            await UpdateImageTrackingConfig(config);

            m_LastSessionConfig.CopyFrom(config);
            m_IsUpdateConfigLock = false;
            return(true);
        }
Example #3
0
 public NativeConfigration(NativeInterface nativeInterface)
 {
     m_NativeInterface            = nativeInterface;
     m_LastSessionConfig          = new NRSessionConfig();
     m_NativeTrackableImage       = m_NativeInterface.NativeTrackableImage;
     m_TrackableImageDatabaseDict = new Dictionary <string, ulong>();
 }
 public NativeConfigration(NativeInterface nativeInterface)
 {
     m_NativeInterface            = nativeInterface;
     m_LastSessionConfig          = NRSessionConfig.CreateInstance(typeof(NRSessionConfig)) as NRSessionConfig;
     m_NativeTrackableImage       = m_NativeInterface.NativeTrackableImage;
     m_TrackableImageDatabaseDict = new Dictionary <string, ulong>();
 }
 public void SetConfiguration(NRSessionConfig config)
 {
     if (config == null)
     {
         return;
     }
     NativeAPI.Configration.UpdateConfig(config);
 }
        public void UpdateConfig(NRSessionConfig config)
        {
            if (m_ConfigHandle == 0)
            {
                m_ConfigHandle = this.Create();
            }

            if (m_ConfigHandle == 0)
            {
                NRDebugger.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;
                    }
                    var result = SetTrackableImageDataBase(m_ConfigHandle, 0);
                    NRDebugger.Log("[Disable trackable image] result : " + result);
                    break;

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

                default:
                    break;
                }

                m_ImageTrackingMode = config.ImageTrackingMode;
            }
        }
Example #7
0
 /// <summary>
 /// ValueType copy from another SessionConfig object into this one.
 /// </summary>
 /// <param name="other"></param>
 public void CopyFrom(NRSessionConfig other)
 {
     OptimizedRendering    = other.OptimizedRendering;
     PlaneFindingMode      = other.PlaneFindingMode;
     ImageTrackingMode     = other.ImageTrackingMode;
     TrackingImageDatabase = other.TrackingImageDatabase;
     EnableNotification    = other.EnableNotification;
     ErrorTipsPrefab       = other.ErrorTipsPrefab;
 }
Example #8
0
        public void SetConfiguration(NRSessionConfig config)
        {
            if (config == null)
            {
                return;
            }
#if !UNITY_EDITOR_OSX
            NativeAPI.Configration.UpdateConfig(config);
#endif
        }
Example #9
0
 private Task UpdatePlaneFindMode(NRSessionConfig config)
 {
     return(Task.Run(() =>
     {
         var currentmode = this.GetPlaneFindMode(m_ConfigHandle);
         if (currentmode != config.PlaneFindingMode)
         {
             SetPlaneFindMode(m_ConfigHandle, config.PlaneFindingMode);
         }
     }));
 }
Example #10
0
        public void SetConfiguration(NRSessionConfig config)
        {
            if (config == null)
            {
                return;
            }

#if !UNITY_EDITOR
            AsyncTaskExecuter.Instance.RunAction(() =>
            {
                NRDebugger.Log("AsyncTaskExecuter: UpdateConfig");
                NativeAPI.Configration.UpdateConfig(config);
            });
#endif
        }
Example #11
0
        /// <summary>
        /// ValueType check if two NRSessionConfig objects are equal.
        /// </summary>
        /// <returns>True if the two NRSessionConfig objects are value-type equal, otherwise false.</returns>
        public override bool Equals(object other)
        {
            NRSessionConfig otherConfig = other as NRSessionConfig;

            if (other == null)
            {
                return(false);
            }

            if (OptimizedRendering != otherConfig.OptimizedRendering ||
                PlaneFindingMode != otherConfig.PlaneFindingMode ||
                ImageTrackingMode != otherConfig.ImageTrackingMode ||
                TrackingImageDatabase != otherConfig.TrackingImageDatabase)
            {
                return(false);
            }

            return(true);
        }
Example #12
0
        private Task UpdateImageTrackingConfig(NRSessionConfig config)
        {
            return(Task.Run(() =>
            {
                switch (config.ImageTrackingMode)
                {
                case TrackableImageFindingMode.DISABLE:
                    var result = SetTrackableImageDataBase(m_ConfigHandle, 0);
                    if (result)
                    {
                        m_TrackableImageDatabaseDict.Clear();
                    }
                    NRDebugger.Log("[NativeConfigration] Disable trackable image result : " + result);
                    break;

                case TrackableImageFindingMode.ENABLE:
                    if (config.TrackingImageDatabase == null)
                    {
                        return;
                    }

                    if (!m_TrackableImageDatabaseDict.TryGetValue(config.TrackingImageDatabase.GUID, out m_DatabaseHandle))
                    {
                        DeployData(config.TrackingImageDatabase);
                        m_DatabaseHandle = m_NativeTrackableImage.CreateDataBase();
                        m_TrackableImageDatabaseDict.Add(config.TrackingImageDatabase.GUID, m_DatabaseHandle);
                    }
                    result = m_NativeTrackableImage.LoadDataBase(m_DatabaseHandle, config.TrackingImageDatabase.TrackingImageDataPath);
                    NRDebugger.LogFormat("[NativeConfigration] LoadDataBase path:{0} result:{1} ", config.TrackingImageDatabase.TrackingImageDataPath, result);
                    result = SetTrackableImageDataBase(m_ConfigHandle, m_DatabaseHandle);
                    NRDebugger.Log("[NativeConfigration] SetTrackableImageDataBase result : " + result);
                    break;

                default:
                    break;
                }
            }));
        }