private Anchor CreateAnchor(HitResult hitResult)
        {
            AnchorVisual visual = new AnchorVisual(arFragment, hitResult.CreateAnchor());

            visual.SetColor(this, Color.Yellow);
            visual.AddToScene(this.arFragment);
            this.anchorVisuals[string.Empty] = visual;

            this.RunOnUiThread(() =>
            {
                this.scanProgressText.Visibility = ViewStates.Visible;
                if (this.enoughDataForSaving)
                {
                    this.statusText.Text         = "Ready to save";
                    this.actionButton.Text       = "Save cloud anchor";
                    this.actionButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    this.statusText.Text = "Move around the anchor";
                }
            });

            this.currentDemoStep = DemoStep.SaveAnchor;

            return(visual.LocalAnchor);
        }
        private Anchor createAnchor(HitResult hitResult)
        {
            AnchorVisual visual = new AnchorVisual(hitResult.CreateAnchor());

            visual.SetColor(readyColor);
            visual.Render(arFragment);
            anchorVisuals[""] = visual;

            RunOnUiThread(() =>
            {
                scanProgressText.Visibility = ViewStates.Visible;
                if (enoughDataForSaving)
                {
                    statusText.Text         = "Ready to save";
                    actionButton.Text       = "Save cloud anchor";
                    actionButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    statusText.Text = "Move around the anchor";
                }
            });

            currentDemoStep = DemoStep.SaveCloudAnchor;

            return(visual.LocalAnchor);
        }
예제 #3
0
        private Anchor CreateAnchor(HitResult hitResult)
        {
            AnchorVisual visual = new AnchorVisual(hitResult.CreateAnchor());

            visual.SetColor(readyColor);
            visual.AddToScene(this.arFragment);
            this.anchorVisuals[string.Empty] = visual;

            return(visual.LocalAnchor);
        }
        private Anchor createAnchor(HitResult hitResult)
        {
            AnchorVisual visual = new AnchorVisual(hitResult.CreateAnchor());

            visual.SetColor(readyColor);
            visual.Render(arFragment);
            anchorVisuals[""] = visual;

            return(visual.LocalAnchor);
        }
        public void OnTapPlane(HitResult hitResult, Plane plane, MotionEvent motionEvent)
        {
            if (visual != null)
            {
                visual.Destroy();
                visual = null;
            }

            Anchor localAnchor = hitResult.CreateAnchor();

            visual           = new AnchorVisual(arFragment, localAnchor);
            visual.IsMovable = true;
            visual.Shape     = SelectedShape;
            visual.SetColor(arFragment.Context, Color.Yellow);
            visual.AddToScene(arFragment);

            hintText.SetText(Resource.String.hint_adjust_anchor);

            confirmPlacementButton.Enabled = true;
        }
예제 #6
0
        /*
         * Used as the listener for setOnTapArPlaneListener.
         */
        private void OnPlaneTap(HitResult hitResult, Google.AR.Core.Plane unusedPlane, MotionEvent unusedMotionEvent)
        {
            if (andyRenderable == null || hatRenderable == null)
            {
                return;
            }
            // Create the Anchor.
            Anchor anchor = hitResult.CreateAnchor();

            if (anchorNode == null)
            {
                anchorNode = new AnchorNode(anchor);
                anchorNode.SetParent(arFragment.ArSceneView.Scene);

                andy = new SkeletonNode();

                andy.SetParent(anchorNode);
                andy.Renderable = andyRenderable;
                hatNode         = new Node();

                // Attach a node to the bone.  This node takes the internal scale of the bone, so any
                // renderables should be added to child nodes with the world pose reset.
                // This also allows for tweaking the position relative to the bone.
                Node boneNode = new Node();
                boneNode.SetParent(andy);
                andy.SetBoneAttachment(HAT_BONE_NAME, boneNode);
                hatNode.Renderable = hatRenderable;
                hatNode.SetParent(boneNode);
                hatNode.WorldScale    = Vector3.One();
                hatNode.WorldRotation = Quaternion.Identity();
                Vector3 pos = hatNode.WorldPosition;

                // Lower the hat down over the antennae.
                pos.Y -= .1f;

                hatNode.WorldPosition = pos;
            }
        }
예제 #7
0
        private Anchor CreateAnchor(HitResult hitResult)
        {
            AnchorVisual visual = new AnchorVisual(hitResult.CreateAnchor());

            visual.SetColor(readyColor);
            visual.Render(this.arFragment);
            this.anchorVisuals[string.Empty] = visual;

            this.RunOnUiThread(() =>
            {
                this.scanProgressText.Visibility = ViewStates.Visible;
                if (this.enoughDataForSaving)
                {
                    if (visual == null)
                    {
                        return;
                    }

                    if (!this.enoughDataForSaving)
                    {
                        return;
                    }

                    this.RunOnUiThread(() => this.exitButton.Visibility = ViewStates.Gone);

                    this.SetupLocalCloudAnchor(visual);

                    Task.Run(async() =>
                    {
                        try
                        {
                            CloudSpatialAnchor result = await this.cloudAnchorManager.CreateAnchorAsync(visual.CloudAnchor);
                            this.AnchorSaveSuccess(result);
                        }
                        catch (CloudSpatialException ex)
                        {
                            this.AnchorSaveFailed($"{ex.Message}, {ex.ErrorCode}");
                        }
                        catch (Exception ex)
                        {
                            this.AnchorSaveFailed(ex.Message);
                        }
                    });

                    lock (this.progressLock)
                    {
                        this.RunOnUiThread(() =>
                        {
                            this.scanProgressText.Visibility = ViewStates.Gone;
                            this.scanProgressText.Text       = string.Empty;
                            this.textView.Text = "Saving cloud anchor...";
                        });
                    }
                }
                else
                {
                    this.textView.Text = "Move around the anchor";
                }
            });
            this.exitButton.Visibility = ViewStates.Visible;
            return(visual.LocalAnchor);
        }