예제 #1
0
// Finally, hide isTracking UI if we haven't done so already.
            public void OnAnchorUpdated(ARAnchor arAnchor, ARNode arNode)
            {
                if (arAnchor.GetType() == ARAnchor.Type.Plane)
                {
                    var planeAnchor = (ARPlaneAnchor)arAnchor;

                    // Update the mesh surface geometry
                    var node       = surfaces[arAnchor.AnchorId];
                    var plane      = (ViroCore.Surface)node.Geometry;
                    var dimensions = planeAnchor.Extent;
                    plane.Width  = dimensions.X;
                    plane.Height = dimensions.Z;
                }
            }
예제 #2
0
            public void OnAnchorFound(ARAnchor arAnchor, ARNode arNode)
            {
                // Spawn a visual plane if a PlaneAnchor was found
                if (arAnchor.GetType() == ARAnchor.Type.Plane)
                {
                    var planeAnchor = (ARPlaneAnchor)arAnchor;

                    // Create the visual geometry representing this plane
                    var dimensions = planeAnchor.Extent;
                    var plane      = new ViroCore.Surface(1, 1)
                    {
                        Width = dimensions.X, Height = dimensions.Z
                    };

                    // Set a default material for this plane.
                    var material = new Material {
                        DiffuseColor = Color.ParseColor("#BF000000")
                    };
                    plane.Materials = new List <Material>()
                    {
                        material
                    };

                    // Attach it to the node
                    var planeNode = new Node {
                        Geometry = plane
                    };
                    planeNode.SetRotation(new Vector(-Math.ToRadians(90.0), 0, 0));
                    planeNode.SetPosition(planeAnchor.Center);

                    // Attach this planeNode to the anchor's arNode
                    arNode.AddChildNode(planeNode);
                    surfaces.Add(arAnchor.AnchorId, planeNode);

                    // Attach click listeners to be notified upon a plane onClick.
                    planeNode.Click += (s, e) =>
                    {
                        foreach (var listener in mPlaneClickListeners)
                        {
                            listener.OnClick(e.P0, e.P1, e.P2);
                        }
                    };
                    HideIsTrackingLayoutUi();
                }
            }