private void OnAnchorLocated(object sender, AnchorLocatedEvent eventArgs)
        {
            LocateAnchorStatus status = eventArgs.Status;

            if (status == LocateAnchorStatus.AlreadyTracked ||
                status == LocateAnchorStatus.Located)
            {
                this.anchorsToLocate--;
            }

            this.RunOnUiThread(() =>
            {
                if (status == LocateAnchorStatus.AlreadyTracked)
                {
                    // Nothing to do since we've already rendered any anchors we've located.
                }
                else if (status == LocateAnchorStatus.Located)
                {
                    this.RenderLocatedAnchor(eventArgs.Anchor);
                }
                else if (status == LocateAnchorStatus.NotLocatedAnchorDoesNotExist)
                {
                    this.statusText.Text = "Anchor does not exist";
                }
            });
        }
コード例 #2
0
        private void SpatialAnchorsSession_AnchorLocated(object sender, AnchorLocatedEventArgs e)
        {
            LocateAnchorStatus status = e.Status;

            switch (status)
            {
            case LocateAnchorStatus.AlreadyTracked:
                break;

            case LocateAnchorStatus.Located:
            {
                CloudSpatialAnchor anchor = e.Anchor;
                Debug.WriteLine("Cloud Anchor found! Identifier : " + anchor.Identifier);
                AnchorVisual visual = new AnchorVisual
                {
                    cloudAnchor = anchor,
                    identifier  = anchor.Identifier,
                    localAnchor = anchor.LocalAnchor
                };
                this.anchorVisuals[visual.identifier] = visual;
                this.sceneView.Session.AddAnchor(anchor.LocalAnchor);
                this.PlaceCube(visual.localAnchor);
                break;
            }

            case LocateAnchorStatus.NotLocated:
            case LocateAnchorStatus.NotLocatedAnchorDoesNotExist:
                break;
            }

            this.OnAnchorLocated?.Invoke(sender, e);
        }
コード例 #3
0
        private void AnchorLookedUp(string anchorId)
        {
            this.DestroySession();

            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);
            this.cloudAnchorManager.OnAnchorLocated += (sender, args) =>
                                                       this.RunOnUiThread(() =>
            {
                CloudSpatialAnchor anchor = args.Args.Anchor;
                LocateAnchorStatus status = args.Args.Status;

                if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located)
                {
                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor)
                    {
                        CloudAnchor = anchor
                    };
                    foundVisual.AnchorNode.SetParent(this.arFragment.ArSceneView.Scene);
                    string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.Render(this.arFragment);
                    this.textView.Text = foundVisual.CloudAnchor.AppProperties["Label"];
                }
            });

            this.cloudAnchorManager.StartSession();
            AnchorLocateCriteria criteria = new AnchorLocateCriteria();

            criteria.SetIdentifiers(new string[] { anchorId });
            this.cloudAnchorManager.StartLocating(criteria);
        }
コード例 #4
0
        private void AnchorLookedUp(string anchorId)
        {
            Log.Debug("ASADemo", "anchor " + anchorId);
            this.anchorId = anchorId;
            this.DestroySession();

            bool anchorLocated = false;

            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);
            this.cloudAnchorManager.OnAnchorLocated += (sender, args) =>
                                                       this.RunOnUiThread(() =>
            {
                CloudSpatialAnchor anchor = args.Anchor;
                LocateAnchorStatus status = args.Status;

                if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located)
                {
                    anchorLocated = true;

                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor)
                    {
                        CloudAnchor = anchor
                    };
                    foundVisual.AnchorNode.SetParent(this.arFragment.ArSceneView.Scene);
                    string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.AddToScene(this.arFragment);
                    this.anchorVisuals[cloudAnchorIdentifier] = foundVisual;
                }
            });

            this.cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) =>
            {
                this.currentStep = DemoStep.Start;

                this.RunOnUiThread(() =>
                {
                    if (anchorLocated)
                    {
                        this.textView.Text = "Anchor located!";
                    }
                    else
                    {
                        this.textView.Text = "Anchor was not located. Check the logs for errors and\\or create a new anchor and try again.";
                    }

                    this.EnableCorrectUIControls();
                });
            };
            this.cloudAnchorManager.StartSession();
            AnchorLocateCriteria criteria = new AnchorLocateCriteria();

            criteria.SetIdentifiers(new string[] { anchorId });
            this.cloudAnchorManager.StartLocating(criteria);
        }
        private void onAnchorLocated(object sender, AnchorLocatedEventArgs args)
        {
            LocateAnchorStatus status = args.P0.Status;

            RunOnUiThread(() =>
            {
                if (status == LocateAnchorStatus.Located)
                {
                    renderLocatedAnchor(args.P0.Anchor);
                }
                else if (status == LocateAnchorStatus.NotLocatedAnchorDoesNotExist)
                {
                    statusText.Text = "Anchor does not exist";
                }
            });
        }
コード例 #6
0
        private void AnchorLookedUp(string anchorId)
        {
            Log.Debug("ASADemo", "anchor " + anchorId);
            this.anchorId = anchorId;
            this.DestroySession();

            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);
            this.cloudAnchorManager.OnAnchorLocated += (sender, args) =>
                                                       this.RunOnUiThread(() =>
            {
                CloudSpatialAnchor anchor = args.Args.Anchor;
                LocateAnchorStatus status = args.Args.Status;

                if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located)
                {
                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor)
                    {
                        CloudAnchor = anchor
                    };
                    foundVisual.AnchorNode.SetParent(this.arFragment.ArSceneView.Scene);
                    string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.Render(this.arFragment);
                    this.anchorVisuals[cloudAnchorIdentifier] = foundVisual;
                }
            });

            this.cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) =>
            {
                this.currentStep = DemoStep.DemoScreenshotMode;

                this.RunOnUiThread(() =>
                {
                    this.textView.Text = "Anchor located! Grab A Screenshot!";
                    this.EnableCorrectUIControls();
                });
            };
            this.cloudAnchorManager.StartSession();
            AnchorLocateCriteria criteria = new AnchorLocateCriteria();

            criteria.SetIdentifiers(new string[] { anchorId });
            this.cloudAnchorManager.StartLocating(criteria);
        }
コード例 #7
0
        public async void LocateAllAnchors()
        {
            await Task.Delay(2000);

            textView.Text = "Searching for MindRs...";

            // clean up prev session just in case
            DestroySession();

            // start locating
            cloudAnchorManager = new AzureSpatialAnchorsManager(sceneView.Session);

            var anchorLocated = false;

            cloudAnchorManager.OnAnchorLocated += (sender, args) =>
                                                  RunOnUiThread(async() =>
            {
                CloudSpatialAnchor anchor = args.Anchor;
                LocateAnchorStatus status = args.Status;

                if (status == LocateAnchorStatus.AlreadyTracked || status == LocateAnchorStatus.Located)
                {
                    AnchorVisual foundVisual = new AnchorVisual(anchor.LocalAnchor)
                    {
                        CloudAnchor = anchor
                    };

                    var mr = await _mindrService.TryGetContentsForAnchor(anchor.Identifier);
                    textView.Visibility = ViewStates.Visible;
                    textView.Text       = mr != null ? mr.actualDesc : "No data found for MindR.";

                    foundVisual.AnchorNode.SetParent(arFragment.ArSceneView.Scene);
                    string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier;
                    foundVisual.SetColor(foundColor);
                    foundVisual.AddToScene(arFragment, textView.Text);
                    anchorVisuals[cloudAnchorIdentifier] = foundVisual;


                    foundVisual.AnchorNode.SetOnTouchListener(this);
                    anchorLocated = true;
                }
            });

            cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) =>
            {
                currentStep = DemoStep.MindrStart;

                RunOnUiThread(() =>
                {
                    textView.Text = anchorLocated ? "MindR(s) located!" : "Failed to find any MindRs.";

                    EnableCorrectUIControls();
                });
            };

            cloudAnchorManager.StartSession();

            await Task.Delay(2000);

            var ac  = new AnchorLocateCriteria();
            var ids = await _mindrService.GetAllAnchorIds();

            ac.SetIdentifiers(ids.ToArray());
            cloudAnchorManager.StartLocating(ac);
        }