コード例 #1
0
 public static Vector3 FromFlippedZVector3f(this Plugin.Vector3f v)
 {
     return(new Vector3()
     {
         X = v.x, Y = v.y, Z = -v.z
     });
 }
コード例 #2
0
ファイル: Boundary.cs プロジェクト: Chapmania/Juniper
        /// <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 static Vector3[] GetGeometry(Boundary.BoundaryType boundaryType)
        {
            var pointsCount = 0;

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

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

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

                        var points = new Vector3[pointsCount];

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

                        return(points);
                    }
                }
            }

            return(Array.Empty <Vector3>());
        }