Skip to content

Commit

Permalink
2.0.0-preview.14 - 2019/03/05
Browse files Browse the repository at this point in the history
@2019.1
  • Loading branch information
ErikMoczi committed Mar 8, 2019
1 parent ebfd8dc commit 06034ab
Show file tree
Hide file tree
Showing 54 changed files with 1,027 additions and 69 deletions.
5 changes: 5 additions & 0 deletions package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [2.0.0-preview.14] - 2019-03-05
- Initial Production release
- Fix a number of issues causing instabilty when using ML Remote
7 changes: 7 additions & 0 deletions package/CHANGELOG.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions package/Documentation~/com.unity.xr.magicleap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# About Magic Leap XR Plugin

Use the *Magic Leap XR Plugin* package enables Magic Leap Spatial Mapping support via Unity's multi-platform XR API. This package implements the following XR Subsystems:

* [Display](https://docs.unity3d.com/2018.3/Documentation/ScriptReference/Experimental.XR.XRDisplaySubsystem.html) (Not Yet Implemented)
* [Input](https://docs.unity3d.com/2018.3/Documentation/ScriptReference/Experimental.XR.XRInputSubsystem.html) (Not Yet Implemented)
* [Meshing](https://docs.unity3d.com/2018.3/Documentation/ScriptReference/Experimental.XR.XRMeshingSubsystem.html)

This version of *Magic Leap XR Plugin* 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 Plugin

To install this package, follow the instructions in the [Package Manager documentation](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest/index.html).

# Using Magic Leap XR Plugin

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

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

## Spatial Mapper

This package includes one component, `MLSpatialMapper`:

![alt text](images/mlspatialmapper_component.png "MLSpatialMapper Component")

The spatial mapper generates [`Mesh`es](https://docs.unity3d.com/ScriptReference/Mesh.html) from data collected from the Magic Leap One's depth sensor. Each mesh is a relatively small area of the environment. A separate [`GameObject`](https://docs.unity3d.com/ScriptReference/GameObject.html) 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`](https://docs.unity3d.com/ScriptReference/MeshFilter.html) on it. To visualize the meshes, add a [`MeshRenderer`](https://docs.unity3d.com/ScriptReference/MeshRenderer.html). If a [`MeshCollider`](https://docs.unity3d.com/ScriptReference/MeshCollider.html) 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`](https://docs.unity3d.com/ScriptReference/GameObject.html).|
|Type|Whether to generate triangle meshes or a point cloud. If you select point cloud, then the resulting [`Mesh`](https://docs.unity3d.com/ScriptReference/Mesh.html) will have [`MeshTopology.Points`](https://docs.unity3d.com/ScriptReference/MeshTopology.Points.html).
|Level of Detail (LOD)|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.|
|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`](https://docs.unity3d.com/ScriptReference/Transform.html) is used to define this region. The [`transform`](https://docs.unity3d.com/ScriptReference/Transform.html)'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](images/meshing_gizmo.png "Meshing Gizmo")

## 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`](https://docs.unity3d.com/ScriptReference/Camera.html)'s [`GameObject`](https://docs.unity3d.com/ScriptReference/GameObject.html) should have an identity transform to begin with.

![alt text](images/magic_leap_root_camera.png "Magic Leap Root Camera")

If you wish to have the device start at a different location within the Unity scene, we recommend you use a parent [`GameObject`](https://docs.unity3d.com/ScriptReference/GameObject.html) to provide position, rotation, and scale (the `Magic Leap Root` in this image):

![alt text](images/magic_leap_root_with_transform.png "Magic Leap Root")

# Technical details
## Requirements

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

* 2018.3 Magic Leap Technical Preview 9 and later (recommended)

## Known limitations

No known issues.

## Package contents

This version of *Magic Leap XR Plugin* 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.|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added package/Documentation~/images/meshing_gizmo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions package/Editor/MLDashboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
using System.Linq;
using UnityEditor;
using UnityEditor.UIElements;
#if PLATFORM_LUMIN
using UnityEditor.Lumin;
#endif // PLATFORM_LUMIN
using UnityEngine;
using UnityEngine.UIElements;
using UnityEngine.Rendering;

namespace UnityEditor.XR.MagicLeap
{
#if PLATFORM_LUMIN
public class MLDashboard : EditorWindow
{
private IMGUIContainer _remoteChecksUi;
Expand Down Expand Up @@ -193,6 +196,7 @@ private static bool IsRemoteAlreadyRunning
}
}
}
#endif // PLATFORM_LUMIN

internal static class MagicLeapPackageLocator
{
Expand Down
12 changes: 6 additions & 6 deletions package/Editor/Remote/MagicLeapRemoteImportSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ void IDisposable.Dispose()

public class ImportFailureException : Exception
{
const string kHelpMessage = @"Cannot import {0} as it appears to already have been previously imported. Please delete the existing file, restart Unity, and try importing again";
const string kHelpMessage = @"Cannot import {0} as it appears to already have been previously imported. Please delete the existing {1}, restart Unity, and try importing again";

public string HelpMessage
{
get
{
return string.Format(kHelpMessage, Path);
return string.Format(kHelpMessage, Path, System.IO.Path.GetDirectoryName(Path));
}
}

public string Path { get; }

public ImportFailureException(string path) : base(string.Format("Cannot Import {0}", path))
public ImportFailureException(string path) : base(string.Format(kHelpMessage, path, System.IO.Path.GetDirectoryName(path)))
{
Path = path;
}

}

#if UNITY_EDITOR_OSX
Expand Down Expand Up @@ -367,10 +367,10 @@ internal static void ImportSupportLibrares(string destFolder)
var dep_path = Path.GetFullPath(item);
if (!File.Exists(dep_path))
{
UnityDebug.LogFormat("missing dep: {0} for {1}", dep_path, dm.file);
//UnityDebug.LogFormat("missing dep: {0} for {1}", dep_path, dm.file);
Directory.CreateDirectory(Path.GetDirectoryName(dep_path));
var src = Path.Combine(macOSDependencyPath, Path.GetFileName(item));
UnityDebug.LogFormat("searching for {0}: {1}", Path.GetFileName(item), src);
//UnityDebug.LogFormat("searching for {0}: {1}", Path.GetFileName(item), src);
if (File.Exists(src))
File.Copy(src, dep_path);
}
Expand Down
Empty file added package/LICENSE.md
Empty file.
7 changes: 7 additions & 0 deletions package/LICENSE.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added package/QAReport.md
Empty file.
7 changes: 7 additions & 0 deletions package/QAReport.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added package/README.md
Empty file.
7 changes: 7 additions & 0 deletions package/README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified package/Runtime/Lumin/UnityMagicLeap.so
Binary file not shown.
53 changes: 0 additions & 53 deletions package/Runtime/Rendering/MagicLeapCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public enum StabilizationMode : byte
[UsesLuminPlatformLevel(2)]
public sealed class MagicLeapCamera : MonoBehaviour
{
static XRInputSubsystem s_InputSubsystem;
static List<XRInputSubsystemDescriptor> s_Descriptors = new List<XRInputSubsystemDescriptor>();

private Camera m_Camera;
#if ML_RENDERING_VALIDATION
private Color m_PreviousClearColor;
Expand Down Expand Up @@ -116,42 +113,14 @@ void Reset()
stabilizationDistance = (GetComponent<Camera>() != null) ? GetComponent<Camera>().farClipPlane : 1000.0f;
}

void OnDestroy()
{
if (s_InputSubsystem != null)
{
s_InputSubsystem.Destroy();
s_InputSubsystem = null;
}
}

void OnDisable()
{
RenderingSettings.useLegacyFrameParameters = true;
if (s_InputSubsystem != null)
s_InputSubsystem.Stop();
}

void OnEnable()
{
RenderingSettings.useLegacyFrameParameters = false;
#if UNITY_EDITOR && PLATFORM_LUMIN
MagicLeapRemoteManager.canInitializeSubsystems += Init;
#else
Init();
#endif // UNITY_EDITOR && PLATFORM_LUMIN
}

void Init()
{
CreateInputSubsystemIfNeeded();
if (s_InputSubsystem == null)
{
enabled = false;
return;
}

s_InputSubsystem.Start();
}

void Start()
Expand Down Expand Up @@ -202,28 +171,6 @@ void LateUpdate()
}
}

static void CreateInputSubsystemIfNeeded()
{
if (s_InputSubsystem != null)
return;

s_Descriptors.Clear();
SubsystemManager.GetSubsystemDescriptors<XRInputSubsystemDescriptor>(s_Descriptors);

if (s_Descriptors.Count > 0)
{
var descriptorToUse = s_Descriptors[0];
if (s_Descriptors.Count > 1)
{
Type typeOfD = typeof(XRInputSubsystemDescriptor);
Debug.LogWarningFormat("Found {0} {1}s. Using \"{2}\"",
s_Descriptors.Count, typeOfD.Name, descriptorToUse.id);
}

s_InputSubsystem = descriptorToUse.Create();
}
}

public void ValidateFarClip(float scale)
{
if (!m_Camera) return;
Expand Down
5 changes: 0 additions & 5 deletions package/Runtime/UnitySubsystemsManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
"name": "UnityMagicLeap",
"version": "1.0.0",
"libraryName": "UnityMagicLeap",
"inputs": [
{
"disablesLegacyInput": false,
"id": "MagicLeap-Input"
}],
"meshings": [
{
"id": "MagicLeap-Mesh"
Expand Down
Binary file modified package/Runtime/Windows/UnityMagicLeap.dll
Binary file not shown.
Binary file modified package/Runtime/Windows/UnityMagicLeap.dll.lib
Binary file not shown.
Binary file modified package/Runtime/macOS/UnityMagicLeap.bundle
Binary file not shown.
8 changes: 8 additions & 0 deletions package/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package/Tests/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions package/Tests/Editor/EditorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

namespace Tests
{
public class EditorTests
{
// A Test behaves as an ordinary method
[Test]
public void EditorTestsSimplePasses()
{
// Use the Assert class to test conditions
}

// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
// `yield return null;` to skip a frame.
[UnityTest]
public IEnumerator EditorTestsWithEnumeratorPasses()
{
// Use the Assert class to test conditions.
// Use yield to skip a frame.
yield return null;
}
}
}
11 changes: 11 additions & 0 deletions package/Tests/Editor/EditorTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 06034ab

Please sign in to comment.