Beispiel #1
0
        public static NativeArray <ManagedReferenceImage> ToNativeArray(this XRReferenceImageLibrary library, Allocator allocator)
        {
            var managedReferenceImages = new NativeArray <ManagedReferenceImage>(library.count, allocator);

            for (var i = 0; i < library.count; ++i)
            {
                managedReferenceImages[i] = new ManagedReferenceImage(library[i]);
            }

            return(managedReferenceImages);
        }
        public unsafe ARCoreImageDatabase(XRReferenceImageLibrary serializedLibrary)
        {
            if (serializedLibrary == null)
            {
                m_NativePtr = UnityARCore_ImageDatabase_deserialize(default(NativeView <byte>), default(NativeView <ManagedReferenceImage>));
            }
            else
            {
                using (var webRequest = new UnityWebRequest(ARCoreImageTrackingProvider.GetPathForLibrary(serializedLibrary)))
                {
                    webRequest.downloadHandler = new DownloadHandlerBuffer();
                    webRequest.disposeDownloadHandlerOnDispose = true;
                    webRequest.SendWebRequest();
                    while (!webRequest.isDone)
                    {
                    }

                    byte[] libraryBlob = webRequest.downloadHandler.data;
                    if (libraryBlob == null || libraryBlob.Length == 0)
                    {
                        throw new InvalidOperationException(string.Format(
                                                                "Failed to load image library '{0}' - file was empty!", serializedLibrary.name));
                    }

                    var managedReferenceImages = new NativeArray <ManagedReferenceImage>(serializedLibrary.count, Allocator.Temp);
                    try
                    {
                        for (int i = 0; i < serializedLibrary.count; ++i)
                        {
                            managedReferenceImages[i] = new ManagedReferenceImage(serializedLibrary[i]);
                        }

                        fixed(byte *blob = libraryBlob)
                        {
                            m_NativePtr = UnityARCore_ImageDatabase_deserialize(new NativeView <byte>(blob, libraryBlob.Length), managedReferenceImages);
                        }
                    }
                    finally
                    {
                        managedReferenceImages.Dispose();
                    }
                }
            }
        }
 static extern unsafe bool UnityARCore_ImageDatabase_addImage(
     IntPtr database,
     ref ManagedReferenceImage managedReferenceImage,
     void *image, int width, int height, void *name);
Beispiel #4
0
 static extern unsafe void AddImage(
     IntPtr database, IntPtr validator,
     ref ManagedReferenceImage managedReferenceImage,
     void *image, int width, int height, void *name);