Magic leap is adding another dimension to computing where digital respects the physical. They work together to make life much better. Magic Leap One is built for creators who want to change how we experience the world. It drags digital world into the real world. Simply it gives a mixed reality experience to us. Before we take step forward into mixed reality, we have to be clear with these three terms : Virtual reality, Augmented reality and Mixed reality.
What is the difference between Virtual Reality, Augmented Reality and Mixed Reality?
To cut a long story short, here’s the difference between virtual, augmented, and mixed reality technologies:
- Virtual reality (VR) immerses users in a fully artificial digital environment.
- Augmented reality (AR) overlays virtual objects on the real-world environment.
- Mixed reality (MR) not just overlays but interacts with your real world. It anchors virtual objects in the real world.
To get started you need to download the Unity engine tool for Magic Leap Technical Preview and Magic Leap Lumin SDK.
Lumin Sdk :
Unity Technical Preview :
Magic Leap Setup
Step 1 : Install required packages from Magic Leap Package Manager
Download and install the latest Magic Leap Package Manager. Lumin SDK has a lot of magic stuff and tools to help create experiences and apps. We don’t have to cover all that now, so, let’s continue with all this marked packages.
Step 2 : Generate, decorate and experience virtual rooms
With the help of Magic Leap Simulator, You can see your quick changes to Unity Editor without deploying to Magic Leap Headset Devise. This simulator covers the major Lumin SDK features. After creating your own room using Virtual Room Generator, load your room in Magic Leap Simulator. Here you can fully explore your room and test it.
In the Magic Leap Remote – Simulator Mode window
- Click Start Simulator
- In the Simulator window, Click the ☰ menu (the one in the Mini Map window) – Click Load Virtual Room
- Navigate to VirtualDevice\data\VirtualRooms\ExampleRooms in your Lumin SDK installation folder.
- Select an example room of choice
You can also generate your custom room with Virtual Room Generator
Magic Leap with Unity
Hope you are ready with Unity 2018.1.0b8 as it’s essentially required for magic leap demonstration.
Let’s get a new Unity project setup using the Magic Leap template. Templates are a new feature in Unity’s project launcher.
- Open the Unity 2018.1.0b8-MLTP1
- Create new project
- Set project name and location
- [New!] Template: Magic Leap
- Select Create project
- File > Build Settings
- Under the Platform section
- Select Lumin OS
- Click the Switch Platform button below
- Set the Lumin SDK Location path. For example, /User/(User Name)/MagicLeap/mlsdk/v0.11.1
- Close the Build Settings window
Let’s enable Zero Iteration.
- Click the Magic Leap menu at the top of Unity
- Click Enable Zero Iteration
- An Editor Restart Required popup will appear
- Click Restart
- Unity will now restart in OpenGL mode
Let’s zap our cube over to the Simulator window.
- Unity click Play to enter Play Mode
- Our cube now appears in the Eye View window pane of the Simulator
- Use WASD and mouse controls to move around and view the cube from different angles
Remember: The simulator should always be started before pressing Play
As you can see, cube is in the real world but it is not still interacting with real world (here virtual world). You can not drag your cube behind any sofa or under the table or anywhere you want. It will still look like AR. To interact with real world you also need mesh real environment in your Unity. If it is possible then it’s not big deal to put your cube wherever you want in the real world. Yes, Magic Leap provides this functionality to import meshes of real world in Unity. And here we go to drag meshes in Unity.
Meshing in Unity
Meshing is a feature of World Reconstruction that detects real world surfaces and constructs a virtual mesh around those objects.
- Import the Magic Leap Unity Package (Path : /Users/UserName/MagicLeap/tools/unity/v0.11.1).
- Create an empty GameObject, name it MLSpatialMapper.
- Attach an MLSpatialMapper Script (AR->Magic Leap->Spatial Mapper) to the MLSpatialMapper GameObject.
- Create the mesh prefab.
- Select MLSpatialMapper and create a child GameObject, named Original.
- This object acts as a template for creating the meshes. At runtime, MLSpatialMapper will create meshes and set them in the Mesh field of the MeshFilter attached to the Original GameObject.
- Disable the Original GameObject.
- Remove any transform offsets.
- Add a Mesh Renderer component.
- Add a Mesh Filter component
- Add a Mesh Collider component
- Launch the application using the Magic Leap Remote(see the Prerequisites). The mesh should appear shaded pink (since no materials have yet been applied).
- Now let’s apply materials to the mesh.
- Create one Cube and add Rigidbody component to it.
- Launch Simulator and click on play button in Unity.
You will see meshes are derived in scene view in Unity. And your Cube is now interacting with real world. You can put your cube wherever you want in environment.
Now your game characters can come in real world and they can do whatever with respect to real world. Here you can see one demo game in which player is playing with ball in real environment.
It was combined efforts of Damini Hajare, Bhavesh Savaliya and Vaibhav Vasoya.