Ejemplo n.º 1
0
    public Vector3[] GetGeometry(OVRBoundary.BoundaryType boundaryType)
    {
        int num = 0;

        if (OVRPlugin.GetBoundaryGeometry2((OVRPlugin.BoundaryType)boundaryType, IntPtr.Zero, ref num) && num > 0)
        {
            int num2 = num * OVRBoundary.cachedVector3fSize;
            if (OVRBoundary.cachedGeometryNativeBuffer.GetCapacity() < num2)
            {
                OVRBoundary.cachedGeometryNativeBuffer.Reset(num2);
            }
            int num3 = num * 3;
            if (OVRBoundary.cachedGeometryManagedBuffer.Length < num3)
            {
                OVRBoundary.cachedGeometryManagedBuffer = new float[num3];
            }
            if (OVRPlugin.GetBoundaryGeometry2((OVRPlugin.BoundaryType)boundaryType, OVRBoundary.cachedGeometryNativeBuffer.GetPointer(0), ref num))
            {
                Marshal.Copy(OVRBoundary.cachedGeometryNativeBuffer.GetPointer(0), OVRBoundary.cachedGeometryManagedBuffer, 0, num3);
                Vector3[] array = new Vector3[num];
                for (int i = 0; i < num; i++)
                {
                    array[i] = new OVRPlugin.Vector3f
                    {
                        x = OVRBoundary.cachedGeometryManagedBuffer[3 * i],
                        y = OVRBoundary.cachedGeometryManagedBuffer[3 * i + 1],
                        z = OVRBoundary.cachedGeometryManagedBuffer[3 * i + 2]
                    }.FromFlippedZVector3f();
                }
                return(array);
            }
        }
        return(new Vector3[0]);
    }
Ejemplo n.º 2
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.º 3
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)
    {
        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]);
    }