Exemplo n.º 1
0
        public override bool Initialize()
        {
#if UNITY_EDITOR
            if (!MagicLeapRemoteManager.Initialize())
            {
                return(false);
            }
#endif // UNITY_EDITOR
            MagicLeapPrivileges.Initialize();

            ApplySettings();

            // Display Subsystem depends on Input Subsystem, so initialize that first.
            CheckForInputRelatedPermissions();
            CreateSubsystem <XRInputSubsystemDescriptor, XRInputSubsystem>(s_InputSubsystemDescriptors, "MagicLeap-Input");
            CreateSubsystem <XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(s_DisplaySubsystemDescriptors, "MagicLeap-Display");
            if (MagicLeapSettings.currentSettings != null && MagicLeapSettings.currentSettings.enableGestures)
            {
                CreateSubsystem <XRGestureSubsystemDescriptor, XRGestureSubsystem>(s_GestureSubsystemDescriptors, "MagicLeap-Gesture");
            }

            if (CanCreateMeshSubsystem())
            {
                CreateSubsystem <XRMeshSubsystemDescriptor, XRMeshSubsystem>(s_MeshSubsystemDescriptor, "MagicLeap-Mesh");
                if (meshSubsystem != null)
                {
                    MeshingSettings.meshingSettings = MLSpatialMapper.GetDefaultMeshingSettings();
                    MeshingSettings.batchSize       = MLSpatialMapper.Defaults.batchSize;
                    MeshingSettings.density         = MLSpatialMapper.Defaults.density;
                    MeshingSettings.SetBounds(Vector3.zero, Quaternion.identity, MLSpatialMapper.Defaults.boundsExtents);
                }
            }

            return(true);
        }
        public override bool Initialize()
        {
#if UNITY_EDITOR
            if (SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLCore)
            {
                Debug.LogWarning(
                    "To use Magic Leap Zero Iteration mode, the editor must be running under OpenGL.\n" +
                    " 1) Go to Edit -> Project Settings -> Player, and select the first tab there (Standalone Settings)...\n" +
                    " 2) Open the 'Other Settings' section, and uncheck 'Auto Graphics API for Windows' An API list will appear.\n" +
                    " 3) Use the + button to add 'OpenGLCore' to the API list.\n" +
                    " 4) Drag it to the top of the list. The editor will now switch to using OpenGL.\n");
            }

            if (!MagicLeapRemoteManager.Initialize())
            {
                return(false);
            }
#endif // UNITY_EDITOR

#if UNITY_INPUT_SYSTEM
            InputLayoutLoader.RegisterInputLayouts();
#endif
            MagicLeapPrivileges.Initialize();

            ApplySettings();

            // Display Subsystem depends on Input Subsystem, so initialize that first.
            CheckForInputRelatedPermissions();
            CreateSubsystem <XRInputSubsystemDescriptor, XRInputSubsystem>(s_InputSubsystemDescriptors, "MagicLeap-Input");
            CreateSubsystem <XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(s_DisplaySubsystemDescriptors, "MagicLeap-Display");
            CreateSubsystem <XRGestureSubsystemDescriptor, XRGestureSubsystem>(s_GestureSubsystemDescriptors, "MagicLeap-Gesture");

            if (CanCreateMeshSubsystem())
            {
                CreateSubsystem <XRMeshSubsystemDescriptor, XRMeshSubsystem>(s_MeshSubsystemDescriptor, "MagicLeap-Mesh");
                if (meshSubsystem != null)
                {
                    // Register native callbacks for feature API
                    meshSubsystem.RegisterNativeSubsystemCallbacks();

                    MeshingSettings.meshingSettings = MLSpatialMapper.GetDefaultMeshingSettings();
                    MeshingSettings.batchSize       = MLSpatialMapper.Defaults.batchSize;
                    MeshingSettings.density         = MLSpatialMapper.Defaults.density;
                    MeshingSettings.SetBounds(Vector3.zero, Quaternion.identity, MLSpatialMapper.Defaults.boundsExtents);
                }
            }

            // Now that subsystem creation is strictly handled by the loaders we must create the following subsystems
            // that live in ARSubsystems
            CreateSubsystem <XRSessionSubsystemDescriptor, XRSessionSubsystem>(s_SessionSubsystemDescriptors, "MagicLeap-Session");
            CreateSubsystem <XRPlaneSubsystemDescriptor, XRPlaneSubsystem>(s_PlaneSubsystemDescriptors, "MagicLeap-Planes");
            CreateSubsystem <XRAnchorSubsystemDescriptor, XRAnchorSubsystem>(s_AnchorSubsystemDescriptors, "MagicLeap-Anchor");
            CreateSubsystem <XRRaycastSubsystemDescriptor, XRRaycastSubsystem>(s_RaycastSubsystemDescriptors, "MagicLeap-Raycast");
            CreateSubsystem <XRImageTrackingSubsystemDescriptor, XRImageTrackingSubsystem>(s_ImageTrackingSubsystemDescriptors, "MagicLeap-ImageTracking");

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Applies the configured observation extents.
        /// </summary>
        protected override void ConfigureObserverVolume()
        {
            base.ConfigureObserverVolume();

            using (ConfigureObserverVolumePerfMarker.Auto())
            {
                // Update the observer
                MeshingSettings.SetBounds(ObserverOrigin, ObserverRotation, ObservationExtents);
            }
        }
Exemplo n.º 4
0
        public override bool Initialize()
        {
#if UNITY_EDITOR
            if (SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLCore)
            {
                Debug.LogWarning(
                    "To use Magic Leap Zero Iteration mode, the editor must be running under OpenGL.\n" +
                    " 1) Go to Edit -> Project Settings -> Player, and select the first tab there (Standalone Settings)...\n" +
                    " 2) Open the 'Other Settings' section, and uncheck 'Auto Graphics API for Windows' An API list will appear.\n" +
                    " 3) Use the + button to add 'OpenGLCore' to the API list.\n" +
                    " 4) Drag it to the top of the list. The editor will now switch to using OpenGL.\n");
            }

            if (!MagicLeapRemoteManager.Initialize())
            {
                return(false);
            }
#endif // UNITY_EDITOR

#if UNITY_INPUT_SYSTEM
            InputLayoutLoader.RegisterInputLayouts();
#endif
            MagicLeapPrivileges.Initialize();

            ApplySettings();

            // Display Subsystem depends on Input Subsystem, so initialize that first.
            CheckForInputRelatedPermissions();
            CreateSubsystem <XRInputSubsystemDescriptor, XRInputSubsystem>(s_InputSubsystemDescriptors, "MagicLeap-Input");
            CreateSubsystem <XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(s_DisplaySubsystemDescriptors, "MagicLeap-Display");
            if (MagicLeapSettings.currentSettings != null && MagicLeapSettings.currentSettings.enableGestures)
            {
                CreateSubsystem <XRGestureSubsystemDescriptor, XRGestureSubsystem>(s_GestureSubsystemDescriptors, "MagicLeap-Gesture");
            }

            if (CanCreateMeshSubsystem())
            {
                CreateSubsystem <XRMeshSubsystemDescriptor, XRMeshSubsystem>(s_MeshSubsystemDescriptor, "MagicLeap-Mesh");
                if (meshSubsystem != null)
                {
                    MeshingSettings.meshingSettings = MLSpatialMapper.GetDefaultMeshingSettings();
                    MeshingSettings.batchSize       = MLSpatialMapper.Defaults.batchSize;
                    MeshingSettings.density         = MLSpatialMapper.Defaults.density;
                    MeshingSettings.SetBounds(Vector3.zero, Quaternion.identity, MLSpatialMapper.Defaults.boundsExtents);
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Retrieve the confidence values associated with a mesh. Confidence values
        /// range from 0..1. <see cref="requestVertexConfidence"/> must be enabled.
        /// </summary>
        /// <seealso cref="requestVertexConfidence"/>
        /// <param name="meshId">The unique <c>TrackableId</c> of the mesh.</param>
        /// <param name="confidenceOut">A <c>List</c> of floats, one for each vertex in the mesh.</param>
        /// <returns>True if confidence values were successfully retrieved for the mesh with id <paramref name="meshId"/>.</returns>
        public bool TryGetConfidence(TrackableId meshId, List <float> confidenceOut)
        {
            if (confidenceOut == null)
            {
                throw new ArgumentNullException("confidenceOut");
            }

            if (m_MeshSubsystem == null)
            {
                return(false);
            }

            int count    = 0;
            var floatPtr = MeshingSettings.AcquireConfidence(meshId, out count);

            if (floatPtr == IntPtr.Zero)
            {
                return(false);
            }

            confidenceOut.Clear();
            if (count > 0)
            {
                if (s_FloatBuffer == null || count > s_FloatBufferCapacity)
                {
                    s_FloatBuffer         = new float[count];
                    s_FloatBufferCapacity = count;
                }

                Marshal.Copy(floatPtr, s_FloatBuffer, 0, count);
                for (int i = 0; i < count; ++i)
                {
                    confidenceOut.Add(s_FloatBuffer[i]);
                }
            }
            MeshingSettings.ReleaseConfidence(meshId);

            return(true);
        }
Exemplo n.º 6
0
 public static extern void UnityMagicLeap_MeshingUpdateSettings(MeshingSettings newSettings);
Exemplo n.º 7
0
 void UpdateBounds()
 {
     MeshingSettings.SetBounds(transform, boundsExtents);
     transform.hasChanged = false;
 }