Create your first HoloLens application with Mixed Reality Toolkit – Part 1

In the last few years, we have seen a quick evolution of the devices able to offer a great experience inside the world of augmented reality. In 2016, Microsoft released the first generation of its mixed reality device, by the name of HoloLens.

But what does mixed reality mean, exactly? What is the main difference with the augmented one and the virtual one? Well, we can summarise the differences in this way: with augmented reality, we mean the overlaying of virtual objects onto the real-world environment, and by contrast, with virtual reality, we mean the immersion of the user in a fully artificial digital environment. At the same time, with mixed reality, we mean not just overlays, but also anchors of virtual objects to the real world.

The introduction of Microsoft Hololens has really changed the world of the augmented (and mixed) reality. One of the most important features of this device is the ability to understand and to map the surroundings, allowing the virtual objects to interact with the environment and stay anchored to a particular position inside the world space.

If we take a look at the first generation of HoloLens hardware, we can find sensors like IMU (Inertial Measurement Unit), environment understanding and depth cameras, ambient light, microphones, and so on. At the heart of the system, there is HPU (Holographic Process Unit), which allows rendering high-resolution holograms through a complex optical system.

HoloLens – First and Second Generation

After three years, Microsoft has released a new version of this amazing device, by the name of Hololens 2. The most important differences with the first generation of this device relate to:

  • Field of view, which has doubled compared to the previous one.
  • Control and interaction improvement, which allows us to manage the virtual objects more naturally through double-hand gestures and eye-tracking processes.
  • Mounting and stabilisation, which have improved the comfort and balance, leading to an increase in the wearing time.

To simplify the development of applications for its devices, Microsoft also released a Unity SDK, originally named HoloToolkit and now known as MixedRealityToolkit. This SDK allows using the features of the HoloLens device, like gestures recognition, input management, spatial understanding, voice commands, and so on. The latest version of this development kit allows us to also exploit the features of the new HoloLens device (HoloLens 2), like hand-tracking and eye-tracking.

How to create a simple application

First of all, you need to take a look at the software requirements. To get started with MixedRealityToolkit, you have to install the following applications:

Now you have to download the last release of MixedRealityToolkit from the official GitHub repository. Here, you have to get the last available .Foundation Unity package, which is the only one required.

Next, create a new 3D Unity project and import the MRT SDK asset by double-clicking on the downloaded package, then select all the contained items and click on the “Import” button.

At this point, Unity will ask you to apply some changes to the project build settings. Click on the “Apply” button.

The last step consists of initialising the default scene. You have to click on the “Mixed Reality Toolkit > Add to Scene and Configure” button, then select the DefaultMixedRealityToolkitConfigurationProfile. You are done!

Build and Deploy

To build and deploy your application to HoloLens, you need to switch the default build platform. Click on the “File > Build Settings” button and then select Universal Windows Platform. You have to fill in the configuration fields as in the image below:

Click on the “Switch Platform” button to confirm. If your device is HoloLens 1 (first-generation), you have to set the Architecture field to x86, otherwise, x64 should be used. Also, you have to click on the “Add Open Scenes” button to add the current scene to the build process, which can be started by clicking on the “Build And Run” button. For the first project build, you have to choose a target directory where to put the UWP solution that will be generated. Now, plug your HoloLens device into your computer and open the created solution by using Visual Studio, then select the target architecture (x86 or ARM x64) and click on the “Run on Device” button. You are done!

That’s all for now!
In the next part of this tutorial, we are going to exploit some of the most important features of MixedRealityToolkit SDK, like input management, objects interaction, voice commands, spatial understanding, and so on. Don’t miss it!

Happy coding!