From the archive

HoloLens Tutorial - Finalize Spatial Understanding

Last Updated: Apr 24, 2017

Tutorial Accomplishments
  1. Test for Spatial Understanding Completeness
  2. Add Input Manager
  3. Finalizing Spatial Understanding
  This section of the tutorial will wrap up spatial mapping and spatial understanding setting us up to place some holograms in the next section. First we will test to make sure we have a certain level of quality in our spatial understanding. Second when the spatial understanding is high enough quality the user can air tap to Finalize Spatial Understanding.   Test for Spatial Understanding Completeness Open SpatialUnderstandingState.cs and make these changes: https://gist.github.com/CameronVetter/ac92df22301d2affab18695c9ea54d85 These changes cause the Primary Text color to change from White to Yellow when spatial understanding criteria specified in constants is met. The first change is made to the Get property of PrimaryColor. In the previous version it always returned White. This makes a call to DoesScanMeetMinBarForCompletion to determine if  the criteria have been met. In this method we call SpatialUnderstandingDll.Imports.QueryPlayspaceStats which returns an object of PlayspaceStats. This method compares the constants that have been added to determine if our spatial understanding is good enough for the application to continue.   Add Input Manager To finalize spatial understanding the user will air tap. In order to detect user input from the HoloLens the HoloToolkit provides the Input Manager. Open the project in Unity and Add a new gameobject named "Control" in the Hierarchy. Drag the InputManager.prefab from the HoloToolkit (in the Input, Prefabs folder) into the new Control object. This results in a few gameobjects and components getting added to the Control Gameobject. This is everything that is needed to detect input from the HoloLens. The project should now look like this: Finalizing Spatial Understanding When the spatial understanding is good enough for our app, the message should both change color and instructions.  The instructions will also change to tell the user to air tap in order to finish mapping. Update SpatialUnderstandingState.CS to this: https://gist.github.com/CameronVetter/f08a2e926e90378439f59d5cada2480b The class now implements the interfaces IInputClickHandler and ISourceStateHandler.  These interfaces contain OnInputClicked, OnSourceDetected, and OnSourceLost.  The Start method is added making a call to the input manager telling it that this gameobject will subscribe to the input events.  When these events occur the methods implemented by the interfaces are called notifying this class of user input.  Visible hands detected are tracked so that the application can respond to the users hand coming into view. Air taps are detected allowing the user to finalize spatial understanding by calling RequestFinishScan which finalizes spatial understanding. Build the app and run it on the HoloLens.  Map your room and air tap to finalize spatial understanding.  Notice that after finalization is complete all of the gaps in the spatial map are approximated based on the rest of the spatial map.  This is done to make the spatial understanding "water tight" so there is not ambiguity on how objects should be placed.  Be careful not to allow the user to finalize with too many gaps in the spatial understanding or the results of object placement may be disappointing.   Tutorial Index [rps-include post=186]

Originally published January 3, 2017. Preserved from the legacy CameronVetter.com archive.

← Browse archive