Пример #1
0
    private async void FindAzureAnchor(string[] idsToQuery)
    {

        if (cloudManager.Session == null)
        {
            // Creates a new session if one does not exist
            Debug.Log("\ncloudManager.CreateSessionAsync()");
            await cloudManager.CreateSessionAsync();
        }

        // Starts the session if not already started
        Debug.Log("\ncloudManager.StartSessionAsync()");
        await cloudManager.StartSessionAsync();

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // create a query criteria by anchor id
        Debug.Log($"Trying to finding anchors with anchor-id {idsToQuery}");
        anchorLocateCriteria = new AnchorLocateCriteria { Identifiers = idsToQuery };

        // query the cloud anchor
        // Start watching for Anchors
        if (cloudManager != null && cloudManager.Session != null)
        {
            Debug.Log("\ncurrentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria)");
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }

    }
Пример #2
0
    //Start looking for specified anchors
    public void FindAzureAnchor(string AnchorIDtoFind)
    {
        OnFindASAAnchor?.Invoke();

        Debug.Log("Looking for anchor...");
        //Provide list of anchor IDs to locate
        SetUpAnchorIDsToLocate();

        //Start watching for Anchors
        currentWatcher = CloudManager.CreateWatcher();
    }
Пример #3
0
    /// <summary>
    /// Finds an ASA anchor with the given id and sets the transform of the given target gameobject to the anchor position.
    /// </summary>
    /// <param name="id">The identifier of the ASA anchor that is searched for.</param>
    /// <param name="targetGameObject">The gameobject that will be repositioned when an anchor is found.</param>
    public void FindAzureAnchor(string id, GameObject targetGameObject)
    {
        //Guards
        if (id == "" || id == null)
        {
            Debug.Log("The anchor id is not allowed to be null or an empty string. No anchor searched.");
            return;
        }
        if (targetGameObject == null)
        {
            Debug.Log("The target gameobject is not allowed to be null. No anchor searched.");
            return;
        }

        Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // Set up list of anchor IDs to locate
        List <GameObject> gameObjectsWithSameAnchor;

        if (objectAnchors.TryGetValue(id, out gameObjectsWithSameAnchor))
        {
            gameObjectsWithSameAnchor.Add(targetGameObject);
        }
        else
        {
            List <GameObject> gameObjectList = new List <GameObject>();
            gameObjectList.Add(targetGameObject);
            objectAnchors.Add(id, gameObjectList);
        }

        List <string> anchorsToFind = new List <string>();

        anchorsToFind.Add(id);

        anchorLocateCriteria.Identifiers = anchorsToFind.ToArray();
        Debug.Log($"Anchor locate criteria configured to look for Azure anchor with ID '{currentAzureAnchorID}'");

        // Start watching for Anchors
        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
    }
    public void FindAzureAnchor(string id = "")
    {
        trigger = false;

        Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");

        SendTimeServer("ASA", Time.time.ToString() + "Start finding the anchor from Server");

        if (id != "")
        {
            currentAzureAnchorID = id;
        }

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // Set up list of anchor IDs to locate
        List<string> anchorsToFind = new List<string>();

        if (currentAzureAnchorID != "")
        {
            anchorsToFind.Add(currentAzureAnchorID);
        }
        else
        {
            Debug.Log("Current Azure anchor ID is empty");
            return;
        }

        anchorLocateCriteria.Identifiers = anchorsToFind.ToArray();
        Debug.Log($"Anchor locate criteria configured to look for Azure anchor with ID '{currentAzureAnchorID}'");

        // Start watching for Anchors
        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
            cloudManager.AnchorLocated += CloudManager_AnchorLocated;
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
        trigger = true;
        Debug.Log("Successfully download anchor and attach" + Time.time.ToString());
        indicator.GetComponent<MeshRenderer>().material.color = Color.green;
    }
Пример #5
0
    public void FindAzureAnchor(string id = "")
    {
        Debug.Log("\nAnchorModuleScript.FindAzureAnchor()");

        if (id != "")
        {
            currentAzureAnchorID = id;
        }

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        // Set up list of anchor IDs to locate
        List <string> anchorsToFind = new List <string>();

        if (currentAzureAnchorID != "")
        {
            anchorsToFind.Add(currentAzureAnchorID);
        }
        else
        {
            Debug.Log("Current Azure anchor ID is empty");
            return;
        }

        anchorLocateCriteria.Identifiers = anchorsToFind.ToArray();
        Debug.Log($"Anchor locate criteria configured to look for Azure anchor with ID '{currentAzureAnchorID}'");

        // Start watching for Anchors
        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
    }
Пример #6
0
    public void FindAzureAnchorForCoarseRelocalization()
    {
        Debug.Log("\nAnchorModuleScript.FindAzureAnchorForCoarseRelocalization()");

        // Notify AnchorFeedbackScript
        OnFindASAAnchor?.Invoke();

        anchorLocateCriteria.Identifiers = new string[] { };
        Debug.Log($"Anchor locate criteria configured to search Anchors '{anchorLocateCriteria.NearDevice.DistanceInMeters} m from the device, Max Count:{anchorLocateCriteria.NearDevice.MaxResultCount}'");

        // Start watching for Anchors
        if ((cloudManager != null) && (cloudManager.Session != null))
        {
            currentWatcher = cloudManager.Session.CreateWatcher(anchorLocateCriteria);
            Debug.Log("Watcher created");
            Debug.Log("Looking for Azure anchor... please wait...");
        }
        else
        {
            Debug.Log("Attempt to create watcher failed, no session exists");
            currentWatcher = null;
        }
    }