// Use this for initialization
 void Start()
 {
     downloadedMetaData = new LibPlacenote.MapMetadata();
     Input.location.Start();
     mSession = UnityARSessionNativeInterface.GetARSessionNativeInterface();
     StartARKit();
     FeaturesVisualizer.EnablePointcloud();
     LibPlacenote.Instance.RegisterListener(this);
 }
        // Load map and relocalize. Check OnStatusChange function for behaviour upon relocalization
        public void OnLoadMapClicked()
        {
            if (!LibPlacenote.Instance.Initialized())
            {
                notifications.text = "SDK not yet initialized";
                return;
            }

            // Reading the last saved MapID from file
            savedMapID = ReadMapIDFromFile();

            if (savedMapID == null)
            {
                notifications.text = "You haven't saved a map yet";
                return;
            }

            initPanel.SetActive(false);
            mappingPanel.SetActive(false);
            localizedPanel.SetActive(true);


            LibPlacenote.Instance.LoadMap(savedMapID,
                                          (completed, faulted, percentage) =>
            {
                if (completed)
                {
                    // Get the meta data as soon as the map is downloaded
                    LibPlacenote.Instance.GetMetadata(savedMapID, (LibPlacenote.MapMetadata obj) =>
                    {
                        if (obj != null)
                        {
                            downloadedMetaData = obj;

                            // Now try to localize the map
                            LibPlacenote.Instance.StartSession();
                            notifications.text = "Trying to Localize Map: " + savedMapID;
                        }
                        else
                        {
                            notifications.text = "Failed to download meta data";
                            return;
                        }
                    });
                }
                else if (faulted)
                {
                    notifications.text = "Failed to load ID: " + savedMapID;
                }
                else
                {
                    notifications.text = "Download Progress: " + percentage.ToString("F2") + "/1.0)";
                }
            }

                                          );
        }
        // Load map and relocalize. Check OnStatusChange function for behaviour upon relocalization
        public void OnLoadMapClicked()
        {
            // delete the planes.
            ConfigureSession(false, false);

            mInitButtonPanel.SetActive(false);
            mMappingButtonPanel.SetActive(false);
            localizedPanel.SetActive(true);

            if (!LibPlacenote.Instance.Initialized())
            {
                mLabelText.text = "SDK not yet initialized";
                return;
            }

            // Reading the last saved MapID from file
            mCurrMapId = LoadMapIDFromFile();

            LibPlacenote.Instance.LoadMap(mCurrMapId,
                                          (completed, faulted, percentage) =>
            {
                if (completed)
                {
                    // Get the meta data as soon as the map is downloaded
                    LibPlacenote.Instance.GetMetadata(mCurrMapId, (LibPlacenote.MapMetadata obj) =>
                    {
                        if (obj != null)
                        {
                            downloadedMetaData = obj;

                            // Now try to localize the map
                            mLabelText.text = "Trying to Localize Map: " + mCurrMapId;
                            LibPlacenote.Instance.StartSession();
                        }
                        else
                        {
                            mLabelText.text = "Failed to download meta data";
                            return;
                        }
                    });
                }
                else if (faulted)
                {
                    mLabelText.text = "Failed to load ID: " + mCurrMapId;
                }
                else
                {
                    mLabelText.text = "Download Progress: " + percentage.ToString("F2") + "/1.0)";
                }
            }

                                          );
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handles loading of the Placenote map from the Placenote Cloud, and relocalizing
        /// </summary>
        public virtual void LoadMap()
        {
            if (!LibPlacenote.Instance.Initialized())
            {
                notificationText.text = "SDK has not initialized yet!";
                return;
            }

            // Read saved map Id from file
            m_SavedMapId = ReadMapIDFromFile();

            if (mapListView.CurrentMapId != m_SavedMapId)
            {
                m_SavedMapId = mapListView.CurrentMapId;
            }

            notificationText.text = "Loading map...";

            // Manage UI
            ActivateMapList(false);

            LibPlacenote.Instance.LoadMap(
                m_SavedMapId,
                (completed, faulted, percentage) =>
            {
                if (completed)
                {
                    // Download meta data
                    LibPlacenote.Instance.GetMetadata(m_SavedMapId,
                                                      (LibPlacenote.MapMetadata result) =>
                    {
                        if (result != null)
                        {
                            // Store result to downloadedMetaData variable, and use in
                            // OnStatusChange() callback in MainController
                            m_DownloadedMetadata = result;

                            // Try to localize the map
                            LibPlacenote.Instance.StartSession();

                            notificationText.text = "Trying to Localize Map: " + m_SavedMapId;

                            // Manage UI
                            ActivateLoadButton(false);
                            locationDropdown.ClearOptions();

                            // Enable the scan panel UI
                            MainController.Instance.GetGUIController().scanPanel.EnablePanel();

                            isLoaded = true;
                        }
                        else
                        {
                            notificationText.text = "Failed to download meta data";
                            return;
                        }
                    }
                                                      );
                }
                else if (faulted)
                {
                    notificationText.text = "Failed to load Map ID: " + m_SavedMapId;
                }
                else
                {
                    notificationText.text = "Download Progress: " + percentage.ToString("F2") + "/1.0)";
                }
            }
                );
        }
Exemplo n.º 5
0
        // Load map and relocalize. Check OnStatusChange function for behaviour upon relocalization
        public void OnLoadMapClicked()
        {
            if (!LibPlacenote.Instance.Initialized())
            {
                notifications.text = "SDK not yet initialized";
                return;
            }

            /*
             * // Reading the last saved MapID from file
             * savedMapID = ReadMapIDFromFile();
             */

            List <LibPlacenote.MapInfo> infoList = new List <LibPlacenote.MapInfo>();

            LibPlacenote.Instance.SearchMaps(mapName, (mapList) => {
                foreach (LibPlacenote.MapInfo mapInfoItem in mapList)
                {
                    Debug.Log("Map ID: " + mapInfoItem.placeId);
                    if (mapInfoItem.metadata.userdata != null)
                    {
                        Debug.Log(mapInfoItem.metadata.userdata.ToString());
                    }
                    infoList.Add(mapInfoItem);
                }
            });

            Debug.Log("Map Count : " + infoList.Count);
            if (infoList.Count > 0)
            {
                savedMapID = infoList[infoList.Count - 1].placeId;
            }
            else
            {
                notifications.text = "You haven't saved a map yet";
                return;
            }

            initPanel.SetActive(false);
            mappingPanel.SetActive(false);
            localizedPanel.SetActive(true);


            LibPlacenote.Instance.LoadMap(savedMapID,
                                          (completed, faulted, percentage) =>
            {
                if (completed)
                {
                    // Get the meta data as soon as the map is downloaded
                    LibPlacenote.Instance.GetMetadata(savedMapID, (LibPlacenote.MapMetadata obj) =>
                    {
                        if (obj != null)
                        {
                            downloadedMetaData = obj;

                            // Now try to localize the map
                            LibPlacenote.Instance.StartSession();
                            notifications.text = "Trying to Localize Map: " + savedMapID;
                        }
                        else
                        {
                            notifications.text = "Failed to download meta data";
                            return;
                        }
                    });
                }
                else if (faulted)
                {
                    notifications.text = "Failed to load ID: " + savedMapID;
                }
                else
                {
                    notifications.text = "Download Progress: " + percentage.ToString("F2") + "/1.0)";
                }
            }

                                          );
        }