public static PlaneAnchorType GetPlaneAnchorType(this Google.AR.Core.Plane plane)
        {
            var planeType = plane.GetType();

            if (planeType == Google.AR.Core.Plane.Type.HorizontalDownwardFacing)
            {
                return(PlaneAnchorType.HorizontalDownwardFacing);
            }
            else
            {
                return(PlaneAnchorType.HorizontalUpwardFacing);
            }
        }
Exemple #2
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;
            }
        }