示例#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 static void SetMeshingFeature(this XRMeshSubsystem meshSubsystem, Feature feature)
        {
            // TODO (05/25/2020): update this to maintain the flags for the explicit magic leap subsystem
            // TODO (05/25/2020): move get default meshing settings to a shared place (MeshingSettings?)
            var settings = MLSpatialMapper.GetDefaultMeshingSettings();

            if (feature.HasFlag(Feature.Meshing | Feature.PointCloud))
            {
                if (feature.HasFlag(Feature.Meshing) && feature.HasFlag(Feature.PointCloud))
                {
                    throw new InvalidOperationException("Magic Leap does not support surfacing point cloud data while also surfacing meshing.");
                }

                if (feature.HasFlag(Feature.Meshing))
                {
                    settings.flags ^= MLMeshingFlags.PointCloud;
                }

                MeshingSettings.meshingSettings = settings;
            }
            else
            {
                throw new ArgumentException($"Attempted to set invalid feature {feature} on Magic Leap Mesh Subsystem.");
            }
        }
        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);
        }
示例#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);
        }