How-To: Query your Room using Spatial Understanding with HoloLens to detect Walls and Horizontal Surfaces

In this story, I continue showing you how to use the Spatial Understanding module to query your room for walls and horizontal surfaces other than the floor and the ceiling and place some holograms there using what we the learned from last story from this series.

In the previous episode…

This post assume that you come from the first part. If you don’t, please take a look here to get familiar.

… we allow the user to start the scan and request the finish making the Air Tap gesture and then we query the floor scanned for a minimum amount of space to position a chair.

5. Let’s add more Holograms

Now that we have all this set and running, let’s add two more holograms to the scan query results. The first one for the surfaces and other one for the walls.

Probably, you already tested the RoboRaid game in the Hololens (if not, you must). This game use this mechanism to query your surroundings for walls and place your enemies there, creating a very realistic and immersive experience.

  1. Go back to the Unity3D editor and open the ScanManager.cs on Visual Studio. You will need to declare two variables to allow configure the holograms to put on the wall and the surface.

2. Add the methods shown below to query the space scanned for specific empty space for each other topology position (wall and surface). As you may guest from the next code section, the InstanciateObjectOnWall method query for a space in your scanned walls and the InstanciateObjectOnSurface do the same in horizontal surfaces that doesn’t match the floor and the ceiling.

3. Update the ScanStateChanged method, to perform the call for those methods when the scanning status is set to Done.

NOTE: You can find the final version of the ScanManager script here.

4. Save your changes and go back to Unity3D editor. Wait for it to compile last changes and you may see two new properties in the MappingOrchestator GameObject. You can import this little low poly cat as the Hologram to put in a surface and any of this painting as the one to put in the wall. Of course, you can choose your own package to import, please take in count to adjust the dimensions in each topology query of the scan if so.

5. Once imported, drag the prefabs into the properties of the MappingOrchestator and rebuild your solution and deploy to your HoloLens device or Emulator.

6. Test your final Project

When you’ve deployed your application to your HoloLens Device or Emulator, you can see the difference from the previous run test that you must see a hologram in your wall and another in a surface. In the video below you can watch a demo from the published code.

Conclusion

In this series of post, we reviewed a fundamental part of the Mixed Reality Platform such as the Spatial Mapping and how to leverage with the Spatial Understanding library to easily query your environment. We saw the scanning flow (Request Begin, Scanning, Request Stop, Query), and how to instantiate holograms in wherever surface we want (floor, wall and horizontal surfaces) in an arbitrary result location from the scan made by the user.

Further Reading

You can follow this links to get more information about this topics.

  • Spatial Mapping — Detailed information about the classes, prefabs and shared involved in this module.
  • Holograms 240 — To learn how to give a shared experience for more than one user in the same room, sharing the holograms coordinates across devices.

Thanks to Nicolás Bello Camilletti

Originally published by Sebastian Gambolati for SOUTHWORKS on Medium 08 March 2018