private void AnchorLookedUp(string anchorId) { Log.Debug("ASADemo", "anchor " + anchorId); this.anchorId = anchorId; DestroySession(); bool anchorLocated = false; cloudAnchorManager = new AzureSpatialAnchorsManager(sceneView.Session); cloudAnchorManager.OnAnchorLocated += (sender, args) => 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(arFragment.ArSceneView.Scene); string cloudAnchorIdentifier = foundVisual.CloudAnchor.Identifier; foundVisual.SetColor(foundColor); foundVisual.AddToScene(arFragment); anchorVisuals[cloudAnchorIdentifier] = foundVisual; } }); cloudAnchorManager.OnLocateAnchorsCompleted += (sender, args) => { currentStep = DemoStep.Start; RunOnUiThread(() => { if (anchorLocated) { textView.Text = "Anchor located!"; } else { textView.Text = "Anchor was not located. Check the logs for errors and\\or create a new anchor and try again."; } EnableCorrectUIControls(); }); }; cloudAnchorManager.StartSession(); AnchorLocateCriteria criteria = new AnchorLocateCriteria(); criteria.SetIdentifiers(new string[] { anchorId }); cloudAnchorManager.StartLocating(criteria); }
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); }