Skip to main content
Version: 20 Mar 2024

MagicLeapFeature

NameSpace: MagicLeapSupport

Enables the Magic Leap OpenXR Loader for Android, and modifies the AndroidManifest to be compatible with ML2.

Inherits from:
OpenXRFeature

Public Methods

void ApplyNearClip

public void ApplyNearClip(
ref float zNear
)

Parameters

TypeNameDescription
ref floatzNear

void ApplyToCamera

public void ApplyToCamera(
Camera camera,
bool warnIfNearClipChanged =true
)

Parameters

TypeNameDescription
Cameracamera
boolwarnIfNearClipChanged

MLResult ConvertSystemTimeToXrTime

Converts a timestamp from a value captured by the system clock to an equivalent XrTime value

public static MLResult ConvertSystemTimeToXrTime(
long timestampNs,
out long xrTime
)

Parameters

TypeNameDescription
longtimestampNsThe system's monotonic clock timestamp represented in nanoseconds. An example might be DateTime.Ticks /100 .
out longxrTimeThe system time converted to respective XrTime.

Returns:


MLResult ConvertSystemTimeToXrTime

Converts a timestamp from a value captured by the system clock to an equivalent XrTime value

public static MLResult ConvertSystemTimeToXrTime(
TimeSpec timeSpec,
out long xrTime
)

Parameters

TypeNameDescription
TimeSpectimeSpecThe system's monotonic clock timestamp represented as a C timespec.
out longxrTimeThe system time converted to respective XrTime.

Returns:


MLResult ConvertXrTimeToSystemTime

Converts a timestamp provided by OpenXR to the equivalent monotonic system clock value.

public static MLResult ConvertXrTimeToSystemTime(
long xrTime,
out long timestampNs
)

Parameters

TypeNameDescription
longxrTimeAn XrTime value, such as provided by another API, measured in nanoseconds.
out longtimestampNsConverted equivalent timestamp, calculated using clock_gettime() with CLOCK_MONOTONIC .

Returns:


MLResult ConvertXrTimeToSystemTime

Converts a timestamp provided by OpenXR to the equivalent monotonic system clock value.

public static MLResult ConvertXrTimeToSystemTime(
long xrTime,
out TimeSpec timeSpec
)

Parameters

TypeNameDescription
longxrTimeAn XrTime value, such as provided by another API, measured in nanoseconds.
out TimeSpectimeSpecConverted equivalent timestamp, calculated using clock_gettime() with CLOCK_MONOTONIC .

Returns:


void SetNearClipPolicy

public void SetNearClipPolicy(
NearClipMode mode
)

Parameters

TypeNameDescription
NearClipModemode

Protected Methods

HookGetInstanceProcAddr

protected override IntPtr HookGetInstanceProcAddr(
IntPtr func
)

Parameters

TypeNameDescription
IntPtrfunc

OnAppSpaceChange

protected override void OnAppSpaceChange(
ulong xrSpace
)

Parameters

TypeNameDescription
ulongxrSpace

OnInstanceCreate

protected override bool OnInstanceCreate(
ulong xrInstance
)

Parameters

TypeNameDescription
ulongxrInstance

OnInstanceDestroy

protected override void OnInstanceDestroy(
ulong xrInstance
)

Parameters

TypeNameDescription
ulongxrInstance

OnSessionBegin

protected override void OnSessionBegin(
ulong xrSession
)

Parameters

TypeNameDescription
ulongxrSession

OnSessionCreate

protected override void OnSessionCreate(
ulong xrSession
)

Parameters

TypeNameDescription
ulongxrSession

OnSessionDestroy

protected override void OnSessionDestroy(
ulong xrSession
)

Parameters

TypeNameDescription
ulongxrSession

OnSessionEnd

protected override void OnSessionEnd(
ulong xrSession
)

Parameters

TypeNameDescription
ulongxrSession

OnSessionStateChange

protected override void OnSessionStateChange(
int oldState,
int newState
)

Parameters

TypeNameDescription
intoldState
intnewState

OnSubsystemCreate

protected override void OnSubsystemCreate()

OnSubsystemDestroy

protected override void OnSubsystemDestroy()

Public Attributes

FarClipPolicy


public FarClipMode FarClipPolicy => farClipPolicy;


FeatureId

The feature id string. This is used to give the feature a well known id for reference.


public const string FeatureId = "com.magicleap.openxr.feature.ml2";


MaxFarZ


public float MaxFarZ => NativeBindings.MLOpenXRGetMaxFarClippingPlane();


MinNearZ


public float MinNearZ => NativeBindings.MLOpenXRGetMinNearClippingPlane();


NearClipPolicy


public NearClipMode NearClipPolicy => nearClipPolicy;


RecommendedFarZ


public float RecommendedFarZ => NativeBindings.MLOpenXRGetRecommendedFarClippingPlane();


RecommendedNearZ


public float RecommendedNearZ => NativeBindings.MLOpenXRGetRecommendedNearClippingPlane();


Public Enums

FarClipMode

EnumeratorValueDescription
NoneDo not restrict the Camera's far clip plane distance.
MaximumRestrict the Camera's far clip plane distance to no more than the maximum allowed by the device.
RecommendedRestrict the Camera's far clip plane to no more than the distance recommended by Magic Leap.

NearClipMode

EnumeratorValueDescription
MinimumRestrict the Camera's near clip plane to no less than the absolute minimum allowed (25cm).
RecommendedRestrict the Camera's near clip plane to no less than the distance configured in the system's settings.