private void AnchorDeleteSuccess(AnchorVisual visual)
 {
     this.saveCount           -= 1;
     this.ignoreMainButtonTaps = false;
     Debug.WriteLine("LOCAL ANCHOR:: " + visual.identifier);
     visual.node.Geometry.FirstMaterial.Diffuse.Contents = this.deletedColor;
 }
Example #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);
        }
Example #3
0
        private SCNNode PlaceCube(ARAnchor anchor)
        {
            AnchorVisual visual = this.anchorVisuals.Values.FirstOrDefault(a => a.localAnchor == anchor);

            if (visual is null)
            {
                return(null);
            }

            Debug.WriteLine($"renderer:nodeForAnchor with local anchor {anchor} at {anchor.Transform}");
            SCNBox box = new SCNBox {
                Width = 0.2f, Height = 0.2f, Length = 0.2f
            };

            if (visual.identifier != this.unsavedAnchorId)
            {
                box.FirstMaterial.Diffuse.Contents = this.foundColor;
            }
            else
            {
                box.FirstMaterial.Diffuse.Contents = this.readyColor;
            }

            this.localAnchorCube = box;
            SCNNode cubeNode = new SCNNode
            {
                Position = visual.localAnchor.Transform.ToPosition(),
                Geometry = box
            };

            this.sceneView.Scene.RootNode.AddChildNode(cubeNode);
            visual.node = cubeNode;

            return(visual.node);
        }
Example #4
0
        protected virtual void AnchorSaveSuccess(CloudSpatialAnchor result)
        {
            this.saveCount += 1;
            this.localAnchorCube.FirstMaterial.Diffuse.Contents = this.savedColor;
            this.targetId = result.Identifier;
            Console.WriteLine("ASADemo: created anchor: " + this.targetId);

            AnchorVisual visual = this.anchorVisuals[this.unsavedAnchorId];

            visual.cloudAnchor = this.cloudAnchor;
            visual.identifier  = this.cloudAnchor.Identifier;
            this.anchorVisuals[visual.identifier] = visual;

            this.anchorVisuals.TryRemove(this.unsavedAnchorId, out _);
            this.localAnchor = null;
        }
Example #5
0
        public void CreateLocalAnchor(ref NMatrix4 transform)
        {
            if (this.localAnchor != null)
            {
                return;
            }

            this.localAnchor = new ARAnchor(transform);
            this.sceneView.Session.AddAnchor(this.localAnchor);

            // Put the local anchor in the anchorVisuals list with a special key
            AnchorVisual visual = new AnchorVisual
            {
                identifier  = this.unsavedAnchorId,
                localAnchor = this.localAnchor
            };

            this.anchorVisuals[visual.identifier] = visual;

            this.PlaceCube(this.localAnchor);

            this.UpdateMainStatusTitle("Create Cloud Anchor (once at 100%)");
        }