Ejemplo n.º 1
0
    /// <summary>
    /// Returns an array of 3d points (in clockwise order) that define the specified boundary type.
    /// All points are returned in local tracking space shared by tracked nodes and accessible through OVRCameraRig's trackingSpace anchor.
    /// </summary>
    public Vector3[] GetGeometry(OVRBoundary.BoundaryType boundaryType)
    {
        if (OVRManager.loadedXRDevice != OVRManager.XRDevice.Oculus)
        {
#if UNITY_2017_1_OR_NEWER
            if (Boundary.TryGetGeometry(cachedGeometryList, (boundaryType == BoundaryType.PlayArea) ? Boundary.Type.PlayArea : Boundary.Type.TrackedArea))
            {
                Vector3[] arr = cachedGeometryList.ToArray();
                return(arr);
            }
#endif
            Debug.LogError("This functionality is not supported in your current version of Unity.");
            return(null);
        }

        int pointsCount = 0;
        if (OVRPlugin.GetBoundaryGeometry2((OVRPlugin.BoundaryType)boundaryType, IntPtr.Zero, ref pointsCount))
        {
            if (pointsCount > 0)
            {
                int requiredNativeBufferCapacity = pointsCount * cachedVector3fSize;
                if (cachedGeometryNativeBuffer.GetCapacity() < requiredNativeBufferCapacity)
                {
                    cachedGeometryNativeBuffer.Reset(requiredNativeBufferCapacity);
                }

                int requiredManagedBufferCapacity = pointsCount * 3;
                if (cachedGeometryManagedBuffer.Length < requiredManagedBufferCapacity)
                {
                    cachedGeometryManagedBuffer = new float[requiredManagedBufferCapacity];
                }

                if (OVRPlugin.GetBoundaryGeometry2((OVRPlugin.BoundaryType)boundaryType, cachedGeometryNativeBuffer.GetPointer(), ref pointsCount))
                {
                    Marshal.Copy(cachedGeometryNativeBuffer.GetPointer(), cachedGeometryManagedBuffer, 0, requiredManagedBufferCapacity);

                    Vector3[] points = new Vector3[pointsCount];

                    for (int i = 0; i < pointsCount; i++)
                    {
                        points[i] = new OVRPlugin.Vector3f()
                        {
                            x = cachedGeometryManagedBuffer[3 * i + 0],
                            y = cachedGeometryManagedBuffer[3 * i + 1],
                            z = cachedGeometryManagedBuffer[3 * i + 2],
                        }.FromFlippedZVector3f();
                    }

                    return(points);
                }
            }
        }

        return(new Vector3[0]);
    }
Ejemplo n.º 2
0
	/// <summary>
	/// Returns a vector that indicates the spatial dimensions of the specified boundary type. (x = width, y = height, z = depth)
	/// </summary>
	public Vector3 GetDimensions(OVRBoundary.BoundaryType boundaryType)
	{
		if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus)
			return OVRPlugin.GetBoundaryDimensions((OVRPlugin.BoundaryType)boundaryType).FromVector3f();

		else
		{
#if !USING_XR_SDK && !REQUIRES_XR_SDK
			Vector3 dimensions;
			if (Boundary.TryGetDimensions(out dimensions, (boundaryType == BoundaryType.PlayArea) ? Boundary.Type.PlayArea : Boundary.Type.TrackedArea))
				return dimensions;
#endif
			return Vector3.zero;
		}
	}
Ejemplo n.º 3
0
    /// <summary>
    /// Returns a vector that indicates the spatial dimensions of the specified boundary type. (x = width, y = height, z = depth)
    /// </summary>
    public Vector3 GetDimensions(OVRBoundary.BoundaryType boundaryType)
    {
        if (OVRManager.loadedXRDevice == OVRManager.XRDevice.Oculus)
        {
            return(OVRPlugin.GetBoundaryDimensions((OVRPlugin.BoundaryType)boundaryType).FromVector3f());
        }

        else
        {
            Vector3 dimensions;
            if (Boundary.TryGetDimensions(out dimensions, (boundaryType == BoundaryType.PlayArea) ? Boundary.Type.PlayArea : Boundary.Type.TrackedArea))
            {
                return(dimensions);
            }
            return(Vector3.zero);
        }
    }
Ejemplo n.º 4
0
 public static bool TryGetGeometry(List <Vector3> geometry)
 {
     Boundary.Type boundaryType = Boundary.Type.PlayArea;
     return(Boundary.TryGetGeometry(geometry, boundaryType));
 }
Ejemplo n.º 5
0
 public static bool TryGetDimensions(out Vector3 dimensionsOut, [DefaultValue("Type.PlayArea")] Boundary.Type boundaryType)
 {
     return(Boundary.TryGetDimensionsInternal(out dimensionsOut, (int)boundaryType));
 }
Ejemplo n.º 6
0
 public static bool TryGetDimensions(out Vector3 dimensionsOut)
 {
     Boundary.Type boundaryType = Boundary.Type.PlayArea;
     return(Boundary.TryGetDimensions(out dimensionsOut, boundaryType));
 }