Exemple #1
0
    private void OnInputEndEdit(string text)
    {
        m_CloudReferenceId = text;

        m_CloudAnchor = AnchorManager.ResolveCloudAnchorId(text);

        if (m_CloudAnchor == null)
        {
            OutputText.text = "Could not resolve CloudAnchor with ID = " + text;
            return;
        }

        m_AppMode = AppMode.WaitingForResolvedReferencePoint;
    }
    public IEnumerator ResolveAnchor()
    {
        check = true;
        ReadFile();
        cloudanchor = anchorManager.ResolveCloudAnchorId(cloudid);


        if (cloudanchor != null)
        {
            pendingcloudanchor.Add(cloudanchor);
            while (true)
            {
                if (cloudanchor.cloudAnchorState == CloudAnchorState.Success)
                {
                    checktext.text = "success";
                    Instantiate(anchorprefeb, cloudanchor.transform);

                    break;
                }
                checktext.text = cloudanchor.cloudAnchorState.ToString();
                yield return(null);
            }
        }
        else
        {
            yield return(new WaitForSeconds(1.0f));

            check = false;
            count++;
            checktext.text = "fail" + count;
        }
    }
    public void Resolve(int index)
    {
        _arDebugManager.LogInfo($"Resolve executing #{index + 1} id #{anchorToResolveList[index]}");

        anchorToResolve        = anchorToResolveList[index];
        cloudAnchorList[index] = _arAnchorManager.ResolveCloudAnchorId(anchorToResolve);

        if (cloudAnchorList[index] == null)
        {
            _arDebugManager.LogInfo($"Resolve result #{index + 1} is null, id #{anchorToResolve}");
        }
    }
    public void Resolve(int index)
    {
        _arDebugManager.LogInfo($"Resolve executing #{index + 1} id #{anchorToResolveList[index]}");


        cloudAnchorList[index] = _arAnchorManager.ResolveCloudAnchorId(anchorToResolveList[index]);

        // if (cloudAnchorList[index] == null)
        // {
        //     arDebugManager.LogError($"Failed to resolve cloud achor #{index + 1} id {cloudAnchorList[index].cloudAnchorId}");
        //     // TODO
        //     numOfToBeResolved--;
        // }
    }
    public void Resolve()
    {
        debugtext.text = "Resolve executing";

        cloudanchor = anchormanager.ResolveCloudAnchorId(anchorToResolve);

        if (cloudanchor == null)
        {
            debugtext.text = "Failed to resolve cloud achor id " + cloudanchor.cloudAnchorId;
        }
        else
        {
            anchorHostInProgress = true;
        }
    }
Exemple #6
0
    public void Resolve()
    {
        //ARDebugManager.Instance.LogInfo("Resolve executing");

        cloudAnchor = arAnchorManager.ResolveCloudAnchorId(anchorToResolve);

        if (cloudAnchor == null)
        {
            // ARDebugManager.Instance.LogError($"Failed to resolve cloud achor id {cloudAnchor.cloudAnchorId}");
        }
        else
        {
            anchorResolveInProgress = true;
        }
    }
Exemple #7
0
    private void printScreen(Node key)
    {
        m_CloudReferenceId = string.Empty;

        m_CloudReferencePoint =
            AnchorManager.ResolveCloudAnchorId(key.cloudAnchorId);
        if (m_CloudReferencePoint == null)
        {
            OutputText.text = "Resolve Failed!";
            printScreen(key);
            return;
        }

        // Wait for the reference point to be ready.
        m_AppMode = AppMode.WaitingForResolvedReferencePoint;
    }
Exemple #8
0
    private void OnInputEndEdit(string text)
    {
        m_CloudReferenceId = string.Empty;

        m_CloudReferencePoint =
            AnchorManager.ResolveCloudAnchorId(text);
        if (m_CloudReferencePoint == null)
        {
            OutputText.text = "Resolve Failed!";
            m_AppMode       = AppMode.TouchToHostCloudReferencePoint;
            return;
        }

        // Wait for the reference point to be ready.
        m_AppMode = AppMode.WaitingForResolvedReferencePoint;
    }
 /// <summary>
 /// Resolves the Cloud Anchor Id and instantiate a Cloud Anchor on it.
 /// </summary>
 /// <param name="cloudAnchorId">The Cloud Anchor Id to be resolved.</param>
 private void ResolveCloudAnchorId(string cloudAnchorId)
 {
     _cloudAnchorsExampleController.OnAnchorInstantiated(false);
     _cloudAnchor = _anchorManager.ResolveCloudAnchorId(cloudAnchorId);
     if (_cloudAnchor == null)
     {
         Debug.LogErrorFormat("Client could not resolve Cloud Anchor {0}.", cloudAnchorId);
         _cloudAnchorsExampleController.OnAnchorResolved(
             false, "Client could not resolve Cloud Anchor.");
         _shouldResolve     = true;
         _shouldUpdatePoint = false;
     }
     else
     {
         _shouldResolve     = false;
         _shouldUpdatePoint = true;
     }
 }
    private bool LoadCloudAnchor()
    {
        string cloudAnchorId = PlayerPrefs.GetString("cloud_anchor_id");

        if (cloudAnchorId != null)
        {
            WorldAnchorCloud = ARAnchorManager.ResolveCloudAnchorId(cloudAnchorId);

            if (WorldAnchorCloud == null)
            {
                Notifications.Instance.ShowNotification("Cloud anchor fail", "Cloud anchor couldn't be loaded");
                Debug.Log("Cloud anchor fail: Cloud anchor couldn't be loaded " + cloudAnchorId);
                return(false);
            }

            return(true);
        }
        return(false);
    }
    public void onOriginRegistered()
    {
        if (this.origin == null)
        {
            origin = anchorManager.ResolveCloudAnchorId(gameState.originId);
        }
        else if (this.origin.cloudAnchorState == CloudAnchorState.Success)
        {
            Vector3 localCameraPos = origin.transform.InverseTransformPoint(playerCamera.transform.position);
            Vector3 localCameraRot = origin.transform.InverseTransformDirection(playerCamera.transform.rotation.eulerAngles);

            CmdInstantiateInOriginSpace(localCameraPos, localCameraRot);
        }
        else if (this.origin.cloudAnchorState != CloudAnchorState.TaskInProgress)
        {
            Debug.Log("Had trouble resolving the origin: " + this.origin.cloudAnchorState.ToString());
            Debug.Log("Trying again...");
            this.origin = null;
        }
    }
Exemple #12
0
    async void spawnCubeAtAnchorWithId(string id)
    {
        await Task.Run(() =>
        {
            ARCloudAnchor anchor = anchorManager.ResolveCloudAnchorId(id);

            while (anchor.cloudAnchorState == CloudAnchorState.TaskInProgress)
            {
            }                                                                   //Pause until the client gets a response from the cloud anchor service

            if (anchor.cloudAnchorState == CloudAnchorState.Success)
            {
                // Spawn a cube at the location of the cloud anchor
                GameObject newCube = Instantiate(cube, Vector3.zero, Quaternion.identity);
                newCube.transform.SetParent(anchor.transform, false);

                Debug.Log("Successfully instantiated cube at cloud anchor with id: " + id);
            }
            else
            {
                Debug.LogError("Failed to resolve cloud anchor with error: " + anchor.cloudAnchorState);
            }
        });
    }
Exemple #13
0
    void Resolving()
    {
        if (PlayerPrefs.HasKey(cloudAnchorKey) == false)
        {
            return;
        }

        messageText.text = "";
        // 클라우드 앵커 ID 받아옴. (포톤, 파이어베이스)
        strCloudAnchorId = PlayerPrefs.GetString(cloudAnchorKey);

        // 클라우드 앵커 ID로 CloudAnchor 로드
        cloudAnchor = anchorManager.ResolveCloudAnchorId(strCloudAnchorId);

        if (cloudAnchor == null)
        {
            messageText.text = "클라우드 앵커 리졸브 실패";
        }
        else
        {
            messageText.text = $"클라우드 앵커 리졸브 성공 : {cloudAnchor.cloudAnchorId}";
            mode             = Mode.RESOLVE_PENDING;
        }
    }
Exemple #14
0
    void Update()
    {
        if (m_AppMode == AppMode.TouchToHostCloudAnchor)
        {
            OutputText.text = m_AppMode.ToString();

            if (Input.touchCount >= 1 &&
                Input.GetTouch(0).phase == TouchPhase.Began &&
                !EventSystem.current.IsPointerOverGameObject(
                    Input.GetTouch(0).fingerId))
            {
                List <ARRaycastHit> hitResults = new List <ARRaycastHit>();
                RaycastManager.Raycast(Input.GetTouch(0).position, hitResults);
                if (hitResults.Count > 0)
                {
                    Pose pose = hitResults[0].pose;

                    // Create a reference point at the touch.
                    ARAnchor anchor =
                        AnchorManager.AddAnchor(
                            hitResults[0].pose);

                    // Create Cloud Reference Point.
                    m_CloudAnchor =
                        AnchorManager.HostCloudAnchor(
                            anchor);
                    if (m_CloudAnchor == null)
                    {
                        OutputText.text = "Create Failed!";
                        return;
                    }

                    // Wait for the reference point to be ready.
                    m_AppMode = AppMode.WaitingForHostedAnchor;
                }
            }
        }
        else if (m_AppMode == AppMode.WaitingForHostedAnchor)
        {
            OutputText.text = m_AppMode.ToString();

            CloudAnchorState cloudAnchorState =
                m_CloudAnchor.cloudAnchorState;
            OutputText.text += " - " + cloudAnchorState.ToString();

            if (cloudAnchorState == CloudAnchorState.Success)
            {
                GameObject cloudAnchor = Instantiate(
                    HostedPointPrefab,
                    Vector3.zero,
                    Quaternion.identity);
                cloudAnchor.transform.SetParent(
                    m_CloudAnchor.transform, false);

                cloudAnchorIdQueue.Enqueue(m_CloudAnchor.cloudAnchorId);
                StartCoroutine(saveAnchor(m_CloudAnchor.cloudAnchorId, GPS.Instance.latitude, GPS.Instance.longitude));
                createMessage(m_CloudAnchor.cloudAnchorId);
                m_CloudAnchor = null;

                m_AppMode = AppMode.ResolveCloudAnchor;
            }
        }
        else if (m_AppMode == AppMode.ResolveCloudAnchor)
        {
            OutputText.text = m_AppMode.ToString();
            //if there is a breadcrumb left to load
            if (cloudAnchorIdQueue.Count >= 1)
            {
                m_CloudAnchorId = cloudAnchorIdQueue.Dequeue();
                OutputText.text = m_CloudAnchorId;
                m_CloudAnchor   = AnchorManager.ResolveCloudAnchorId(m_CloudAnchorId);
                startTime       = DateTime.Now;

                if (m_CloudAnchor == null)
                {
                    OutputText.text = "Resolve Failed!";
                    m_CloudAnchorId = string.Empty;
                    //m_AppMode = AppMode.TouchToHostCloudAnchor;
                    return;
                }

                m_CloudAnchorId = string.Empty;

                // Wait for the reference point to be ready.
                m_AppMode = AppMode.WaitingForResolvedAnchor;
            }
            else
            {
                //if the queue is empty, return to placing anchors
                m_AppMode = AppMode.TouchToHostCloudAnchor;
            }
        }
        else if (m_AppMode == AppMode.WaitingForResolvedAnchor)
        {
            OutputText.text = m_AppMode.ToString();

            CloudAnchorState cloudAnchorState =
                m_CloudAnchor.cloudAnchorState;
            OutputText.text += " - " + cloudAnchorState.ToString();

            if (cloudAnchorState == CloudAnchorState.Success)
            {
                GameObject cloudAnchor = Instantiate(
                    ResolvedPointPrefab,
                    Vector3.zero,
                    Quaternion.identity);
                cloudAnchor.transform.SetParent(
                    m_CloudAnchor.transform, false);

                StartCoroutine(getMessage(m_CloudAnchor.cloudAnchorId, cloudAnchor.GetComponentInChildren <Text>()));

                m_CloudAnchor = null;

                if (cloudAnchorIdQueue.Count <= 0)
                {
                    //if there are no more anchors to process, go back to placing anchors
                    m_AppMode = AppMode.TouchToHostCloudAnchor;
                }
                else
                {
                    //if there are more anchors to resolve, do that.
                    m_AppMode = AppMode.ResolveCloudAnchor;
                }
            }
            else if (cloudAnchorState == CloudAnchorState.TaskInProgress)
            {
                if (startTime.HasValue && (DateTime.Now - startTime.Value).TotalSeconds >= maxWait)
                {
                    m_CloudAnchor = null;

                    if (cloudAnchorIdQueue.Count <= 0)
                    {
                        //if there are no more anchors to process, go back to placing anchors
                        m_AppMode = AppMode.TouchToHostCloudAnchor;
                    }
                    else
                    {
                        //if there are more anchors to resolve, do that.
                        m_AppMode = AppMode.ResolveCloudAnchor;
                    }
                }
            }
            else if (cloudAnchorState == CloudAnchorState.ErrorResolvingCloudIdNotFound)
            {
                m_CloudAnchor = null;

                if (cloudAnchorIdQueue.Count <= 0)
                {
                    //if there are no more anchors to process, go back to placing anchors
                    m_AppMode = AppMode.TouchToHostCloudAnchor;
                }
                else
                {
                    //if there are more anchors to resolve, do that.
                    m_AppMode = AppMode.ResolveCloudAnchor;
                }
            }
        }
        else if (m_AppMode == AppMode.WaitingForQueue)
        {
            if (isQueueReady)
            {
                m_AppMode = AppMode.ResolveCloudAnchor;
                return;
            }
            //check if the gps has initialized and the populate coroutine has not started
            else if (!isQueueStarted && GPS.Instance.latitude != 0)
            {
                StartCoroutine(PopulateAnchorQueue(GPS.Instance.latitude, GPS.Instance.longitude));
                isQueueStarted = true;
            }
        }
    }