/// <summary>
        /// Uses the TryGetGeometry call and Unity Bounds to create a volume out of the setup boundary.
        /// </summary>
        public void CalculateBoundaryVolume()
        {
#if !UNITY_WSA
            // This always returns false in WindowsMR.
            if (!UnityEngine.Experimental.XR.Boundary.configured)
            {
                Debug.Log("Boundary not configured.");
                return;
            }
#endif

            if (XRDevice.GetTrackingSpaceType() != TrackingSpaceType.RoomScale)
            {
                Debug.Log("No boundary for non-room scale experiences.");
                return;
            }

            // Get all the bounds setup by the user.
            var boundaryGeometryPoints = new List <Vector3>(0);
            if (UnityEngine.Experimental.XR.Boundary.TryGetGeometry(boundaryGeometryPoints, UnityEngine.Experimental.XR.Boundary.Type.TrackedArea))
            {
                if (boundaryGeometryPoints.Count > 0)
                {
                    for (int pointIndex = 0; pointIndex < boundaryGeometryPoints.Count; pointIndex++)
                    {
                        boundaryFloor = Math.Min(boundaryFloor, boundaryGeometryPoints[pointIndex].y);
                    }

                    boundaryGeometryEdges = EdgeHelpers.ConvertVector3ListToEdgeArray(boundaryGeometryPoints);

                    inscribedRectangle = new InscribedRectangle(boundaryGeometryEdges);
                }
            }
            else
            {
                Debug.Log("TryGetGeometry returned false.");
            }
        }
Beispiel #2
0
 /// <summary>
 /// Constructor that takes in a list of points and sets a fixed random seed to get repeatable results.
 /// </summary>
 public InscribedRectangle(IList <Vector3> points, int randomSeed) : this(EdgeHelpers.ConvertVector3ListToEdgeArray(points), randomSeed)
 {
 }