docs.unity3d.com

    About Magic Leap XR Support

    Use the Magic Leap XR Support package to enable Magic Leap via Unity's multi-platform XR SDK. This package implements the following XR Subsystems:

    • Display
    • Input
    • Meshing

    This version of Magic Leap XR Support supports the meshing functionality provided by the Magic Leap One:

    • Generate meshes of the environment
    • Generate point clouds of the environment

    Installing Magic Leap XR Support

    To install this package, follow the instructions in the Package Manager documentation.

    Using Magic Leap XR Support

    The Magic Leap XR Support implements the native endpoints required for meshing using Unity's multi-platform XR API.

    Inclusion of the Magic Leap XR Support will result in the inclusion of a C# component, runtime libraries, and plugin metadata.

    Spatial Mapper

    This package includes the MLSpatialMapper component:

    alt text

    The spatial mapper generates Mesh objects from data collected from the Magic Leap One's depth sensor. Each mesh is a relatively small area of the environment. A separate GameObject is created for each generated mesh.

    Field Description
    Mesh Prefab This is the prefab that will be instantiated for each generated mesh. The prefab should at least have a MeshFilter on it. To visualize the meshes, add a MeshRenderer. If a MeshCollider is present, then a physics collider will be generated as well. This happens on a background thread, so it will not stall the main thread.
    Compute Normals If true, will request that the device also generate a normal for each vertex. If false, normals will be calculated from the triangle data.
    Mesh Parent The parent transform for the generated meshes. By default, the MLSpatialMapper will select its own parent, so that the generated meshes will be siblings of the MLSpatialMapper's GameObject.
    Type Whether to generate triangle meshes or a point cloud. If you select point cloud, then the resulting Mesh will have MeshTopology.Points.
    Level of Detail (Deprecated) The detail of the generated meshes. Lower levels of detail will result in simplified meshes, and will reduce CPU and GPU load, but will be less accurate. Higher LOD levels will be more accurate, but require more CPU and GPU resources. This property is deprecated, and has been replaced by density.
    Mesh Density Controls the size and spacing of triangles in meshes. The scale goes from low density at 0 (big triangles) to high density at 1 (small triangles). Higher density meshes require more CPU and GPU resources.
    Mesh Queue Size The number of concurrent meshes to generate. Each frame, the MLSpatialMapper will add meshes to a generation queue as necessary. Larger values will lead to heavier CPU usage, but will generate meshes faster.
    Fill Hole Length Perimeter (in meters) of holes you wish to have filled.
    Polling Rate How often to check for updates, in seconds. More frequent updates will increase CPU usage.
    Batch Size Maximum number of meshes to update per batch. Larger values are more efficient, but have higher latency.
    Planarize If true, the system will planarize the returned mesh (planar regions will be smoothed out).
    Disconnected Component Area Any component that is disconnected from the main mesh and which has an area (in meters squared) less than this size will be removed.
    Request Vertex Confidence If true, the system will compute the confidence values for each vertex, ranging from 0 to 1.
    Remove Mesh Skirt If true, the mesh skirt (overlapping area between two meshes) will be removed.

    Bounds

    Meshes are only generated inside a specific region, relative to the Magic Leap One's starting position. The MLSpatialMapper's transform is used to define this region. The transform's localPosition, localRotation, and localScale are used for this calculation.

    A green, transparent box is drawn in Unity's Scene View to indicate the area in which meshing will occur:

    alt text

    Spaces

    Meshes are generated in "device space", also know as "session relative space". When the Magic Leap One boots up, its initial position is (0, 0, 0). All meshing data is relative to this initial location.

    The Camera's GameObject should have an identity transform to begin with.

    alt text

    If you wish to have the device start at a different location within the Unity scene, we recommend you use a parent GameObject to provide position, rotation, and scale (the Magic Leap Root in this image):

    alt text

    Gesture

    Subsystem implementation to provide for recognition and tracking of gestures provided from the appropriate device. This subsystem relies on the com.unity.xr.interactionsubsystem package for it's core implementation (see that package's documentation for further details/types).

    The MagicLeapGestureSubsystem component manages a low-level interface for polling for Magic Leap gesture changes. If this component is added to a scene, it is possible to poll for any gesture events each frame. The following gestures and gesture data are provided:

    • MagicLeapKeyPoseGestureEvent - Event that fires when a key pose gesture changes. See the Magic Leap documentation for further documenation on key poses.
      • id - Unique GestureId that identifies this gesture.
      • state - GestureState that indicates the state of this gesture (Started, Updated, Completed, Canceled or Discrete).
      • keyPose - MagicLeapKeyPose indicating type of key pose that has been detected. Valid key poses are Finger, Fist, Pinch, Thumb, LShape, OpenHand, Ok, CShape, NoPose, NoHand are all valid key poses.
      • hand - MagicLeapHand indicating the hand source for this gesture (Left or Right);
    • MagicLeapTouchpadGestureEvent - Event that fires when a touchpad gesture changes. See the Magic Leap documentation for further documenation on the touchpad.
      • id - Unique GestureId that identifies this gesture.
      • state - GestureState that indicates the state of this gesture (Started, Updated, Completed, Canceled or Discrete).
      • controllerId - The controller id associated with this gesture.
      • angle - Angle from the center of the touchpad to the finger.
      • direction - MagicLeapTouchpadGestureDirection indicating the direction of this gesture (None, Up, Down, Left, Right, In, Out, Clockwise, CounterClockwise).
      • fingerGap - Distance between the two fingers performing the gestures in touchpad distance. The touchpad is defined as having extents of [-1.0,1.0] so this distance has a range of [0.0,2.0].
      • positionAndForce - Gesture position (x,y) and force (z). Position is in the [-1.0,1.0] range and force is in the [0.0,1.0] range.
      • radius - For radial gestures, this is the radius of the gesture. The touchpad is defined as having extents of [-1.0,1.0] so this radius has a range of [0.0,2.0].
      • speed - Speed of gesture. Note that this takes on different meanings depending on the gesture type being performed:
      • type - MagicLeapInputControllerTouchpadGestureType indicating the type of this gesture (None, Tap, ForceTapDown, ForceTapUp, ForceDwell, SecondForceDown, LongHold, RadialScroll, Swipe, Scroll, Pinch).

    Additionally, the MagicLeapGestures component can be used to provide a simpler polling mechanism for a simpler, event-based interface for listening to gestures. This component provides a number of events that be hooked into to detect gesture events when they occur:

    • onKeyPoseGestureChanged - Occurs whenever a key pose gesture changes state.
    • onTouchpadGestureChanged - Occurs whenever a touchpad gesture changes state.
    • onActivate - Occurs whenever the cross-platform activate gesture occurs. See the com.unity.xr.interactionsubsystems package documentation for more details.

    Also see the relevant Magic Leap documentation about gestures for supported device information.

    Technical details

    Requirements

    This version of Magic Leap XR Support is compatible with the following versions of the Unity Editor:

    • Unity 2019.3

    Known limitations

    No known issues.

    Package contents

    This version of Magic Leap XR Support includes:

    • A shared library which provides implementation of the XR Subsystems listed above
    • A plugin metadata file

    Document revision history

    Date Reason
    June 1, 2018 Create initial documentation.
    August 17, 2018 Minor updates to docs to refer to 2018.3 version.
    June 20, 2019 Minor updates to reflect 2019.2
    June 29. 2019 Update name to Magic Leap XR Support
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023
    OSZAR »