/// <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> private Vector3[] GetGeometry(OculusApi.BoundaryType boundaryType) { int pointsCount = 0; if (OculusApi.GetBoundaryGeometry(boundaryType, IntPtr.Zero, ref pointsCount)) { //Assume if the number of points returned in the boundary is the same, it is the same boundary. if (cachedPoints.Length == pointsCount) { return(cachedPoints); } 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 (OculusApi.GetBoundaryGeometry(boundaryType, cachedGeometryNativeBuffer.GetPointer(), ref pointsCount)) { Marshal.Copy(cachedGeometryNativeBuffer.GetPointer(), cachedGeometryManagedBuffer, 0, requiredManagedBufferCapacity); cachedPoints = new Vector3[pointsCount]; for (int i = 0; i < pointsCount; i++) { cachedPoints[i] = new OculusApi.Vector3f { x = cachedGeometryManagedBuffer[3 * i + 0], y = cachedGeometryManagedBuffer[3 * i + 1], z = cachedGeometryManagedBuffer[3 * i + 2], }; } } } } return(cachedPoints); }
/// <summary> /// Returns a vector that indicates the spatial dimensions of the specified boundary type. (x = width, y = height, z = depth) /// </summary> /// <remarks> /// Reserved for Future use. /// </remarks> private Vector3 GetDimensions(OculusApi.BoundaryType boundaryType) { return(OculusApi.GetBoundaryDimensions(boundaryType).ToVector3FlippedZ()); }