Skip to main content
Version: 14 Oct 2024

Magic Leap OpenXR

The MagicLeap OpenXR plugin is required by all other plugins in the SDK that wrap OpenXR apis.

The plugin can be enabled from the plugin browser. In the Unreal editor, selected Edit -> Plugins. Enable "Magic Leap OpenXR" to enable the plugin.

note

The "Magic Leap" (non-OpenXR) plugin does not need to be enabled unless you are planning to use the Voice intents plugin or call legacy ML C SDK functions in your project.

Setting the reference space to use to control the level world origin

When you view your Unreal level on a Magic Leap 2 device, you will see 3d content posed in your physical space. An OpenXR reference space is used to control how the level world origin is located relative to your physical environment.

After enabling the plugin, you can set the OpenXR reference space to use to control the level world origin. See the OpenXR specification at Khronos.org for more detail on the different reference space behaviors- https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#reference-spaces

To set the reference space to use, open Edit -> Project Settings and navigate to the "Magic Leap OpenXR" page under Plugins.

The reference space used to control the world origin can be selected from the dropdown menu.

Function library

A library of static functions are provided to surface MagicLeap platform functionality exposed by several OpenXR extensions. Functions are callable from blueprints.

Include the MagicLeapOpenXRBlueprintFunctionLibrary.h header in the MagicLeapOpenXR module to call these functions in your C++ code.

Global Dimmer

https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_ML_global_dimmer

BP AccessibilityFunction SignatureDescription
BlueprintPurefloat GetGlobalDimmerLevel()Get global dimmer level.
BlueprintCallablevoid SetGlobalDimmerLevel(float Level)Set global dimmer level.

The Global Dimmer value can be set via blueprint using the Set Global Dimmer function from the Magic Leap OpenXR Plugin.

Below is an example of setting the Global Dimmer to maximum opacity at scene start in the Level Blueprint class:

Blueprint setting of Global Dimmer value

The value range for the Global Dimmer is 0-1. For more informaion about dimming priority, visit the Dimmer Feature guides.

MagicLeap Frame Info (native only)

https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_ML_frame_end_info

BP AccessibilityFunction SignatureDescription
BlueprintPurefloat GetFocusDistance()Get focus distance.
BlueprintCallablevoid SetFocusDistance(float FocusDistance)Set focus distance [0-100000] cm.
BlueprintPurebool GetIsProtectedContent()Get is protected content.
BlueprintCallablevoid SetIsProtectedContent(bool bIsProtectedContent)Set is protected content.
BlueprintPurebool GetUseVignette()Get use vignette.
BlueprintCallablevoid SetUseVignette(bool bUseVignette)Set use vignette.

View Configuration Depth Range (native only)

https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_EXT_view_configuration_depth_range

BP AccessibilityFunction SignatureDescription
BlueprintPurefloat GetNearClipDistance()Get near clip.
BlueprintPurefloat GetMinimumNearClipDistance()Get minimum near clip.
BlueprintPurefloat GetRecommendedNearClipDistance()Get recommended near clip.
BlueprintCallablevoid SetNearClipDistance(float NearClipDistance)Set near clip.

Physical World Occlusion (native only)

There are several occlusion modes that can be enabled to mask out regions of the MagicLeap 2 display to allow you to see physical objects in your environment, as though they were in front of the virtual objects.

Controller occlusion

BP AccessibilityFunction SignatureDescription
BlueprintPurebool GetControllerOcclusionEnabled()Check if controller occlusion is enabled
BlueprintCallablebool SetControllerOcclusionEnabled(bool bEnabled)Enable controller occlusion

Hand occlusion

BP AccessibilityFunction SignatureDescription
BlueprintPurebool GetHandsOcclusionEnabled()Check if hands occlusion is enabled
BlueprintCallablebool SetHandsOcclusionEnabled(bool bEnabled)Enable hands occlusion

Occlusion based on output from the depth sensor

BP AccessibilityFunction SignatureDescription
BlueprintPurebool GetDepthSensorOcclusionEnabled()Check if depth sensor occlusion is enabled
BlueprintCallablebool SetDepthSensorOcclusionEnabled(bool bEnabled)Enable depth sensor occlusion
BlueprintPurefloat GetDepthSensorOcclusionMinNearRange()Get depth sensor occlusion min near range
BlueprintPurefloat GetDepthSensorOcclusionMaxNearRange()Get depth sensor occlusion max near range
BlueprintPurefloat GetDepthSensorOcclusionMinFarRange()Get depth sensor occlusion min far range
BlueprintPurefloat GetDepthSensorOcclusionMaxFarRange()Get depth sensor occlusion max far range
BlueprintPurefloat GetDepthSensorOcclusionNearRange()Get depth sensor occlusion near range
BlueprintCallablevoid SetDepthSensorOcclusionNearRange(float NearRange)Set depth occlusion near range
BlueprintPurefloat GetDepthSensorOcclusionFarRange()Get depth sensor occlusion far range
BlueprintCallablevoid SetDepthSensorOcclusionFarRange(float FarRange)Set depth sensor occlusion far range

Environment occlusion

BP AccessibilityFunction SignatureDescription
BlueprintPurebool GetEnvironmentOcclusionEnabled()Check if environment occlusion is enabled
BlueprintCallablebool SetEnvironmentOcclusionEnabled(bool bEnabled)Enable environment occlusion