Example #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);
        }
Example #2
0
            public MagicLeapProvider()
            {
                // ARFoundation often beats XRManagement to the instantiation so often times the MagicLeapPrivileges
                // class will not be available to get privileges from.  Because of this the class is acquired here.
                MagicLeapPrivileges.Initialize();

                m_PerceptionHandle = PerceptionHandle.Acquire();


                if (s_NativeProviderPtr == IntPtr.Zero)
                {
                    s_NativeProviderPtr = Native.Construct();
                }
                if (RequestPrivilegesIfNecessary())
                {
                    if (s_NativeTrackerCreationJobHandle.Equals(default(JobHandle)))
                    {
                        RcoApi.Retain(s_NativeProviderPtr);
                        s_NativeTrackerCreationJobHandle = new CreateNativeImageTrackerJob {
                            nativeProvider = s_NativeProviderPtr
                        }.Schedule();
                    }
                }
                else
                {
                    LogWarning($"Could not start the image tracking subsystem because privileges were denied.");
                }
            }
Example #3
0
 public override bool Deinitialize()
 {
     DestroySubsystem <XRMeshSubsystem>();
     DestroySubsystem <XRDisplaySubsystem>();
     DestroySubsystem <XRGestureSubsystem>();
     MagicLeapPrivileges.Shutdown();
     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);
        }
Example #5
0
        private bool CanCreateMeshSubsystem()
        {
            if (MagicLeapPrivileges.IsPrivilegeApproved((uint)Privileges.WorldReconstruction))
            {
                return(true);
            }
#if DEVELOPMENT_BUILD
            Debug.LogError("Unable to create Mesh Subsystem due to missing 'WorldReconstruction' privilege. Please add to manifest");
#endif // DEVELOPMENT_BUILD
            return(false);
        }
Example #6
0
 private void CheckForInputRelatedPermissions()
 {
     if (!MagicLeapPrivileges.IsPrivilegeApproved((uint)Privileges.ControllerPose))
     {
         Debug.LogWarning("No controller privileges specified; Controller data will not be available via XRInput Subsystem!");
     }
     if (!(MagicLeapPrivileges.IsPrivilegeApproved((uint)Privileges.GesturesConfig) && MagicLeapPrivileges.IsPrivilegeApproved((uint)Privileges.GesturesSubscribe)))
     {
         Debug.LogWarning("No gestures privileges specified; Gesture and Hand data will not be available via XRInput Subsystem!");
     }
 }
 /// <summary>
 /// Allows the user to re-request privileges
 /// </summary>
 /// <returns>
 /// <c>true</c> if the Color Camera privileges were granted and <c>false</c> otherwise.
 /// </returns>
 public bool RequestPrivilegesIfNecessary()
 {
     if (MagicLeapPrivileges.IsPrivilegeApproved(k_MLPrivilegeID_CameraCapture))
     {
         return(true);
     }
     else
     {
         return(MagicLeapPrivileges.RequestPrivilege(k_MLPrivilegeID_CameraCapture));
     }
 }
 bool RequestPrivilegesIfNecessary()
 {
     if (MagicLeapPrivileges.IsPrivilegeApproved(k_MLPivilegeID_PwFoundObjRead))
     {
         return(true);
     }
     else
     {
         return(MagicLeapPrivileges.RequestPrivilege(k_MLPivilegeID_PwFoundObjRead));
     }
 }
            /// <summary>
            /// Destroy the image tracking subsystem.
            /// </summary>
            public override void Destroy()
            {
                if (s_NativeProviderPtr != IntPtr.Zero)
                {
                    Native.Destroy(s_NativeProviderPtr);
                    s_NativeProviderPtr = IntPtr.Zero;
                    s_NativeTrackerCreationJobHandle = default(JobHandle);
                }

                m_PerceptionHandle.Dispose();

                // Release retained privileges class
                MagicLeapPrivileges.Shutdown();
            }
Example #10
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);
        }
 public override bool Deinitialize()
 {
     if (CanCreateMeshSubsystem())
     {
         DestroySubsystem <XRMeshSubsystem>();
     }
     DestroySubsystem <XRDisplaySubsystem>();
     DestroySubsystem <XRGestureSubsystem>();
     DestroySubsystem <XRInputSubsystem>();
     DestroySubsystem <XRImageTrackingSubsystem>();
     DestroySubsystem <XRRaycastSubsystem>();
     DestroySubsystem <XRAnchorSubsystem>();
     DestroySubsystem <XRPlaneSubsystem>();
     DestroySubsystem <XRSessionSubsystem>();
     MagicLeapPrivileges.Shutdown();
     return(true);
 }
 bool IEnumerator.MoveNext() => !MagicLeapPrivileges.IsPrivilegeApproved(m_PrivilegeId);