Exemplo n.º 1
0
 /// <summary>
 /// Sets the tracked plane and initializes the renderer.
 /// </summary>
 public void SetTrackedPlane(TrackedPlane plane)
 {
     trackedPlane = plane;
     trackedPlane.GetBoundaryPolygon(ref polygonVertices);
     planeRenderer.Initialize();
     planeRenderer.UpdateMeshWithCurrentTrackedPlane(trackedPlane.Position, polygonVertices);
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        // If no plane yet, disable the renderer and return.
        if (trackedPlane == null)
        {
            planeRenderer.EnablePlane(false);
            return;
        }

        // If this plane was subsumed by another plane, destroy this object, the other plane's display will render it.
        if (trackedPlane.SubsumedBy != null)
        {
            Destroy(gameObject);
            return;
        }

        // If this plane is not valid or ARCore is not tracking, disable rendering.
        if (trackedPlane.TrackingState != TrackingState.Tracking || Session.Status != SessionStatus.Tracking)
        {
            planeRenderer.EnablePlane(false);
            return;
        }

        // OK! Valid plane, so enable rendering and update the polygon data if needed.
        planeRenderer.EnablePlane(true);
        List <Vector3> newPolygonVertices = new List <Vector3>();

        trackedPlane.GetBoundaryPolygon(newPolygonVertices);
        if (!AreVerticesListEqual(polygonVertices, newPolygonVertices))
        {
            polygonVertices.Clear();
            polygonVertices.AddRange(newPolygonVertices);
            planeRenderer.UpdateMeshWithCurrentTrackedPlane(trackedPlane.CenterPose.position, polygonVertices);
        }
    }