Example #1
0
        protected override void OnResume()
        {
            base.OnResume();

            if (this.sceneView != null && this.sceneView.Session is null)
            {
                SetupSessionForSceneView(this, this.sceneView);
            }

            if (string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountId) || AccountDetails.SpatialAnchorsAccountId == "Set me" ||
                string.IsNullOrWhiteSpace(AccountDetails.SpatialAnchorsAccountKey) || AccountDetails.SpatialAnchorsAccountKey == "Set me")
            {
                Toast.MakeText(this, "\"Set SpatialAnchorsAccountId and SpatialAnchorsAccountKey in AzureSpatialAnchorsManager.java\"", ToastLength.Long)
                .Show();

                this.Finish();
            }
            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);
            this.cloudAnchorManager.StartSession();
            string num = cloudAnchorManager.RetrieveLastAnchorId().Result;

            LocateAnchor(num);

            this.RunOnUiThread(() =>
            {
                this.textView.Text = "Look for anchor";
            });
        }
Example #2
0
        private void initializeSession()
        {
            this.textView.Text = "Scan your environment and place an anchor";
            this.DestroySession();

            this.cloudAnchorManager = new AzureSpatialAnchorsManager(this.sceneView.Session);

            this.cloudAnchorManager.OnSessionUpdated += (_, sessionUpdateArgs) =>
            {
                float progress = sessionUpdateArgs.Args.Status.RecommendedForCreateProgress;
                this.enoughDataForSaving = progress >= 1.0;
                lock (this.progressLock)
                {
                    this.RunOnUiThread(() =>
                    {
                        this.scanProgressText.Text = $"Scan progress is {Math.Min(1.0f, progress):0%}";
                    });

                    if (this.enoughDataForSaving)
                    {
                        // Enable the save button
                        this.RunOnUiThread(() =>
                        {
                            this.textView.Text = "Ready to save";
                        });
                    }
                }
            };

            this.cloudAnchorManager.StartSession();
        }
Example #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);
        }