Mapping our environment

In the previous chapter, we took two routes; the first using low-level APIs and the second simplifying the process by using the SpatialMappingCollider and SpatialMappingRender components. HoloToolkit simplifies this further. To add spatial mapping, we simply drag the SpatialMapping prefab onto the scene. Let's add this now; from the Project panel, enter SpatialMapping into the search bar. One of the results will be the prefab. Drag this one onto the Hierarchy panel to have it added to your scene, as shown:

The properties should look familiar to you as they, are intentionally, similar to what we implemented in the previous chapter. Spatial Mapping Observer and Spatial Mapping Manager are responsible for both scanning and, optionally, making surfaces visible but unlike our implementation, it uses an axis aligned box for its bounding volume, and as opposed to sphere, this uses the property Extends to determine the volume. There is an additional component attached to the SpatialMapping prefab, Object Surface Observer. This component provides a convenient way to use previously baked environments from within the Editor.

Now is a good time to see your progress and view it on the device or emulator. Launch the Build Settings dialog by selecting the menu item File | Build Settings. Click on Add Open Scenes to include the current scene in the build and click on the Build button to build the project.

Once finished, open the root directory of the build and double-click on the solution (.sln) file to open Visual Studio and, finally, build and deploy to the device or emulator. Refer to Chapter 9, Deploying Your Apps to the HoloLens Device and Emulator for details.

As you can see, with minimal effort, we now have access to the physical world. Our next task is to try to better understand this physical world, so we can automatically place the bin. This is the focus of the next section.

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

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