Adding HoloToolkit to your project

Our first job is to get HoloToolkit into our project. To do this, we will be loading a version of HoloToolkit-Unity (original source from https://github.com/Microsoft/HoloToolkit-Unity) that comes bundled with the project files for this book under the directory HoloToolkit-Unity

The version of HoloToolkit used in this chapter was released in late 2016. You can clone this version directly from the original source by running the following commands in the Command Prompt:

git clone https://github.com/Microsoft/HoloToolkit-Unity.git
git checkout cd2fd2f9569552c37ab9defba108e7b7d9999b12

We now will create a Unity package so we can easily import it into our project. Once the HoloToolkit-Unity project is loaded in Unity, select everything in your Project panel. With everything selected, export it as a Unity package via Assets | Export Package. Leaving everything checked, click on the Export button.

The reason for selecting everything is to ensure we include the build and compilation option files rsp, csc, gmcs, and smcs

With HoloToolkit now exported, it's time to create a new project and start making use of it. Assuming you still have Unity open, create a new project from the menu File | New Project and enter an appropriate name and location before clicking on the Create project button.

With your new project now open, import the HoloToolkit package by either double-clicking on the exported package or importing it via the menu Assets | Import Package | Custom Package, ensuring that you select the exported Unity package you created from the previous step. Leaving everything checked, click on the Import button to bring all the files into your project:

As we did before, we will import the project-related assets. From the menu, select Assets | Import | Custom Packages, navigate to where the book resources reside, and select the package PaperTrashBallAssets_START.unitypackage. Leaving everything checked, click on the Import button to import the assets into your package.

Credit and thanks to Daniele De Luca for the use of the models used in this project, available at http://www.blendswap.com/blends/view/19629.

With all the assets now added, let's begin by setting up Unity for developing for the HoloLens. HoloToolkit comes with some useful Editor utilities; we will use two now to help setup our environment. From the menu, select HoloToolkit | Configure | Apply HoloLens Project Settings. This will set your platform to Windows 10 Universal, set Quality Settings to Fastest, and enable Virtual Reality Support.

To perform spatial mapping, we require the spatial perception capability. Enable this via the Capability Settings dialog using the menu HoloTookit | Configure | Apply HoloLens Capability Settings. With the dialog open, check the SpatialPerception capability to enable it as in the following screenshot:

Now, let's set up the camera for HoloLens; you can do this using the menu HoloToolkit | Configure | Apply HoloLens Scene Settings. Selecting this will configure your current scenes Main Camera with the appropriate settings. Alternatively, you can use the prefab that comes with HoloToolkit. Because we already have Main Camera, we will use the menu option. From the menu, select HoloToolkit | Configure | Apply HoloLens Scene Settings.

Our final task is to create new layers that will be assigned to the scanned surfaces and holograms. From the menu, select Edit | Project Settings | Tags and Layers. This will open a panel, Layers as shown in the following screenshot, listing all the layers. As we did in the previous chapter, add SpatialSurface at index 31 and Hologram at index 30. SpatialSurface will be assigned to our surfaces and Hologram will be assigned to our holograms:

Now, with our environment set up, let's turn our attention to providing better feedback to the user.

No doubt we have all experienced applications where the feedback has been inadequate, leaving us feeling lost and, at times, frustrated. In our example, we will use the cursor as our main form of feedback, as we did before, but this time, providing some additional information, such as showing when we have detected the user's hand in the ready state. Along with this, we will also introduce a floating status text field that will tag along with the user's gaze, which will be used to keep the user informed of the current state of the application and could also include any other helpful information that might help the user progress smoothly through the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.39.23