void OnBoundaryChanged(ARPlaneBoundaryChangedEventArgs eventArgs)
        {
            var boundary = m_Plane.boundary;

            if (!ARPlaneMeshGenerators.GenerateMesh(mesh, new Pose(transform.localPosition, transform.localRotation), boundary))
            {
                return;
            }

            var lineRenderer = GetComponent <LineRenderer>();

            if (lineRenderer != null)
            {
                lineRenderer.positionCount = boundary.Length;
                for (int i = 0; i < boundary.Length; ++i)
                {
                    var point2 = boundary[i];
                    lineRenderer.SetPosition(i, new Vector3(point2.x, 0, point2.y));
                }
            }

            var meshFilter = GetComponent <MeshFilter>();

            if (meshFilter != null)
            {
                meshFilter.sharedMesh = mesh;
            }

            var meshCollider = GetComponent <MeshCollider>();

            if (meshCollider != null)
            {
                meshCollider.sharedMesh = mesh;
            }
        }
Exemple #2
0
        void OnBoundaryChanged(ARPlaneBoundaryChangedEventArgs eventArgs)
        {
            // Ignore subsumed planes
            if (m_Plane.boundedPlane.SubsumedById != TrackableId.InvalidId)
            {
                DisableComponents();
                return;
            }

            var center  = eventArgs.center;
            var normal  = eventArgs.normal;
            var polygon = eventArgs.convexBoundary;

            if (!ARPlaneMeshGenerators.GenerateMesh(mesh, m_Plane.boundedPlane.Pose, center, normal, polygon))
            {
                return;
            }

            if (meshUpdated != null)
            {
                meshUpdated(this);
            }

            var lineRenderer = GetComponent <LineRenderer>();

            if (lineRenderer != null)
            {
                lineRenderer.positionCount = polygon.Count;
                for (int i = 0; i < polygon.Count; ++i)
                {
                    lineRenderer.SetPosition(i, polygon[i]);
                }
            }

            var meshFilter = GetComponent <MeshFilter>();

            if (meshFilter != null)
            {
                meshFilter.sharedMesh = mesh;
            }

            var meshCollider = GetComponent <MeshCollider>();

            if (meshCollider != null)
            {
                meshCollider.sharedMesh = mesh;
            }
        }