<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[Mustansir Mukadam - Hololens]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens]]></link><description><![CDATA[Hololens]]></description><pubDate>Thu, 13 Jul 2023 18:26:02 -0700</pubDate><generator>Weebly</generator><item><title><![CDATA[HoloTetris]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/holotetris]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/holotetris#comments]]></comments><pubDate>Tue, 11 Dec 2018 03:19:11 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/holotetris</guid><description><![CDATA[As part of a Hackathon at work, I decided to put my Hololens app development skills to use and create a full fledged holographic application. I feel that designing a game on any platform requires not only the knowledge of developing on that platform, but also stresses the application's UI, functionality, and overall user engagement. And what better game than the world famous tile matching puzzle Tetris!I have decided to make this project completely open source and available on GitHub hereHere's  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">As part of a Hackathon at work, I decided to put my Hololens app development skills to use and create a full fledged holographic application. I feel that designing a game on any platform requires not only the knowledge of developing on that platform, but also stresses the application's UI, functionality, and overall user engagement. And what better game than the world famous tile matching puzzle Tetris!<br /><br />I have decided to make this project completely open source and available on GitHub <a href="https://github.com/unmaskedspirit/HoloTetris" target="_blank">here</a><br /><br /><a href="https://youtu.be/x5PqJZgDlfs" target="_blank">Here's a YouTube link</a> with&nbsp; short video demo of the app. I'd love feedback and comments!<br /><br /></div>]]></content:encoded></item><item><title><![CDATA[Moving Holograms with Gestures]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/moving-holograms-with-gestures]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/moving-holograms-with-gestures#comments]]></comments><pubDate>Mon, 10 Dec 2018 02:55:19 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/moving-holograms-with-gestures</guid><description><![CDATA[It's been radio silence since my last post (I know) but work has kept me super busy!I'm back with what I think was my biggest challenge in developing applications using Hololens - moving holograms using gestures. Granted, the new MRTK has a HandDraggable script (renamed DragAndDropHandler)&nbsp;located here, but I found this script a little complicated for simpler Hololens applications. The script relies on&nbsp;both&nbsp;the camera and hand position and very quickly seems to "lose" the hologram [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">It's been radio silence since my last post (I know) but work has kept me super busy!<br />I'm back with what I think was my biggest challenge in developing applications using Hololens - moving holograms using gestures. Granted, the new MRTK has a HandDraggable script (<em>renamed DragAndDropHandler)&nbsp;</em>located <a href="https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/b170096ebfb6ed9a2c33191df0f500e8f11c5876/Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/DragAndDropHandler.cs" target="_blank">here</a>, but I found this script a little complicated for simpler Hololens applications. The script relies on&nbsp;<strong>both&nbsp;</strong>the camera and hand position and very quickly seems to "lose" the hologram out in the weeds if the user either moves his or her hand or head fast enough.&nbsp;<br /><br />For my requirements (creating HoloTetris), I needed a simpler script where the reliance is on the user's hand position which is monitored on every frame rate once the hologram is engaged, allowing for a smoother movement of holograms across the screen. I named this script ObjectControl which inherits IInputHandler and IFocusable<br /><br />Some of the most useful scripts involve getting and setting the object's position - very useful when engaging and moving the object. Code is provided on GitHub <a href="https://github.com/unmaskedspirit/HoloTetris/blob/master/Scripts/ObjectControl.cs" target="_blank">here </a>and some snippets and highlights are explained below<br />&#8203;&nbsp;</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/setandgetposition.png?1544413577" alt="Picture" style="width:321;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">A couple of useful boolean values <strong>isDragging </strong>and <strong>isEnabled </strong>are<strong>&nbsp;</strong>to keep track of the current status of the object.&nbsp;<br /><br />IInputHandler inherits the <strong>OnInputDown&nbsp;</strong>and&nbsp;<strong>OnInputUp </strong>functions which commence and end the object dragging action.&nbsp;<br />OnInputDown records the event as used (so that the dragging action doesn't get interrupted by another user action until completion).&nbsp;<strong>StartDragging&nbsp;</strong>is another function in MRTK which determines the source that initiated the dragging gesture (hand or controller). The MRTK version of StartDragging also looks for the camera position and the pivot position of the hand. I stripped this script down to simply record the object position at the start of dragging.&nbsp;<br /><br /><strong>UpdateDragging</strong>&nbsp;is another function which is called during Update. Similar to StartDragging, UpdateDragging continues to monitor and update the position of the object based on the hand's current position. The object's new position is calculated by using the&nbsp;<strong>Vector3.Slerp&nbsp;</strong>function which spherically interpolates between the current object's and hand's position to move the object to the new position<br /><em>Vector3 draggedPosition = HostTransform.position + (handDistance * DistanceScale);<br />Vector3 newPosition = Vector3.Slerp(HostTransform.position, draggedPosition, PositionLerpSpeed);<br />SetHostPosition(newPosition)</em><br /><br />Finally, a few functions to gracefully handle exiting the dragging motion, once the user releases the drag gesture. This invokes the OnInputUp inherited funciton, where I release the event (<em>eventData.Use()</em>) before calling a <strong>StopDragging </strong>function to fix the final position of the hologram</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/oninputdown.png?1544497828" alt="Picture" style="width:505;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/startdragging.png?1544497854" alt="Picture" style="width:639;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>]]></content:encoded></item><item><title><![CDATA[Creating UIs for Hololens]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/creating-uis-for-hololens]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/creating-uis-for-hololens#comments]]></comments><pubDate>Tue, 27 Mar 2018 14:34:35 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/creating-uis-for-hololens</guid><description><![CDATA[The previous post focused on creating a simple text popup window based on user interactions. In this post, we take things one step further by creating UIs which can include a combination of text, images, buttons, scrollbars, etc. for a larger interaction set presented to the user. We will be utilizing the Canvas game object in Unity to enable these features.      In the Hierarchy window, right click UI&rarr;Canvas. This creates an empty canvas to the scene. In order to make the canvas visible an [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">The previous post focused on creating a simple text popup window based on user interactions. In this post, we take things one step further by creating UIs which can include a combination of text, images, buttons, scrollbars, etc. for a larger interaction set presented to the user. We will be utilizing the <a href="https://docs.unity3d.com/Manual/UICanvas.html" target="_blank">Canvas game object in Unity</a> to enable these features.</div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph">In the Hierarchy window, right click UI&rarr;Canvas. This creates an empty canvas to the scene. In order to make the canvas visible and interact-able with the Hololens, you have to do the following;<br />1. Change Render Mode to World Space. Unity will prompt you to update the canvas' WorldCamera to use the UIRaycastCamera. Click OK<br />2. Look and feel: This was really tricky and took multiple attempts (and <a href="https://forum.unity.com/threads/unity-ui-on-the-hololens.394629/" target="_blank">research online</a>). Generally you want to set the canvas X,Y,Z position to 0, 0, (some reasonable Z around 5. The canvas scaling should be anywhere between 0.01 and 0.1 (again this number is obtained by trial and error)<br />3. In the canvas Inspector,&nbsp; Add Component&rarr;Layout&rarr;Vertical Layout Group. I like using this because it neatly organizes all the content I eventually place in the canvas. Once you are comfortable with canvas placement and object adjustment, you can disregard this step.<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/canvas-inspector.png?1522163450" alt="Picture" style="width:285;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Great, we have a canvas! Now what?<br /><br /><u><strong>Add Text</strong></u><br />Let's add some text elements to this canvas. In the Hierarchy window, right click UI&rarr;Text. The text game object appears as a child under the canvas.<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/text-script_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Text (script) is not editable (AFAIK). We will add a text mesh component (Add Component&rarr;Mesh&rarr;Mesh Filter). This field is editable, which will come in handy later on in this example. As before, we want a reasonably large font size and lower scale factor to get a crisp font rendering.&nbsp; Since we have used a Vertical Layout Group for the canvas, the text position inside the canvas is frozen. Add the desired text. I also allow both horizontal and vertical overflow for the text.<br /><br /><em>Update (3/28/18): Text components are, in fact, editable. You need to include using UnityEngine.UI to editthe Text fields of objects in a canvas. This is done using GetComponentInChildren&lt;Text&gt;().text = "Insert string here"</em><br /><br /><em>Pro Tip: </em>In this example, the upper left corner of the canvas is the (0,0) position and, just like a regular 2D graph, the lower right corner is (canvas width, -canvas height) coordinate. In our example, that will be (400,-400). You can visually see the canvas origin by the placement of the white cross-hairs on the canvas.<br /><br /><u><strong>Add Button</strong></u><br /><br />Next step is to add a button to the canvas. In the Hierarchy window, right click UI&rarr;Button. The button object appears as a child under the canvas.<br />The button has some interaction controls and settings. These color options change the look and feel of the button depending on the situation. There is also a text component under the button. Type in "Click Here" in the Text (Script) area.<br /><br /><strong><u>Add Sphere</u></strong><br /><br />The final object to add to the scene is a sphere with the red material created in the <a href="http://www.mustansirmukadam.com/hololens/the-first-hologram" target="_blank">previous example</a>. I added this at (1,1,5) with a scale of (0.3,0.3,0.3). The canvas is at (0,0,5) with a scale of (400,200).<br /><br /><u><strong>The Scene</strong></u><br />Now that the components have been added, let's work through the scene and build the scripts.<br />In this scene, we want to do the following:<br />1. If the user gazes at the button, change the color of the ball (<a href="http://www.mustansirmukadam.com/hololens/gaze-101" target="_blank">IFocusable</a>)<br />2. If the user air taps on the button, change the text with a running count of the number of taps (<a href="http://www.mustansirmukadam.com/hololens/airtap-support-for-your-applications" target="_blank">IInputClickHandler</a>)<br /><br />In the Scripts folder, create a new script called ButtonInteraction. We will create two public variables that hold the sphere and the text area. We will also create two private variables that hold the sphere's default color and the click count.<br />In brief, the OnFocusEnter and OnFocusExit scripts will change the default color to a random color and re-instantiate the default color respectively.<br />The OnInputClicked function will increase the click count and change the text mesh in the text area.<br />The code is provided below.<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/ui-button-interaction_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">This is a sample visual of the game scene:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/ui-click-count.png?1522259739" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><em>Assignment: </em>Try adding a second button that resets the count. I'll leave this up to you to do but here are some hints:<br />1. Use the <a href="https://docs.unity3d.com/ScriptReference/Object.FindObjectOfType.html" target="_blank">FindObjectOfType </a>function to access the count number of the script associated with the first button<br />2. Use <strong>get </strong>and <strong>set</strong> methods to access private variables<br /><br /><em>Pro Tip: </em>How can you <a href="https://stackoverflow.com/questions/30344576/how-to-find-all-cube-game-object-in-the-scene" target="_blank">find Primitive objects</a> such as spheres and cubes in your scene? You can use <a href="https://docs.unity3d.com/Manual/Tags.html" target="_blank">tags</a>. This is a clean solution if you want your UI objects to interact with objects in the scene such as players, enemies, objects, etc. <br /></div>]]></content:encoded></item><item><title><![CDATA[Adding tool tips or popup text to objects]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/adding-tool-tips-or-popup-text-to-objects]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/adding-tool-tips-or-popup-text-to-objects#comments]]></comments><pubDate>Fri, 23 Mar 2018 05:47:51 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/adding-tool-tips-or-popup-text-to-objects</guid><description><![CDATA[After a long hiatus, I'm back with more Hololens development!In this tutorial, we will talk about how to add tool tips to holographic objects when you gaze at them. In many scenarios there may be multiple voice and gesture commands that can be used to interact with the object. With the aid of tool tips or popup menus it becomes much easier to make your holographic experiences more user friendly.      The first thing to do is create a new game object by right clicking in Hierarchy &rarr;Create Em [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">After a long hiatus, I'm back with more Hololens development!<br />In this tutorial, we will talk about how to add tool tips to holographic objects when you gaze at them. In many scenarios there may be multiple voice and gesture commands that can be used to interact with the object. With the aid of tool tips or popup menus it becomes much easier to make your holographic experiences more user friendly.<br /></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph">The first thing to do is create a new game object by right clicking in Hierarchy &rarr;Create Empty.&nbsp; Rename this to PopupText. In the Inspector window for this object, click Add Component&rarr;Mesh&rarr;Text Mesh. This text mesh is where you can program the text to be displayed, the font size, style, etc.<br /><br />Next, create a new folder under Assets called Prefab. This will be the place to store all user created objects (very useful for games) and things like text boxes, prompts, etc. Drag the PopupText object and place it in this folder. You have created your first prefab! Now you can delete this from the Hierarchy. A prefab can be instantiated and destroyed in any script. Learn more about Prefabs <a href="https://docs.unity3d.com/Manual/Prefabs.html" target="_blank">here</a>. The prefab settings I used can be found at the end of this tutorial. <br /></div>  <div class="paragraph">Instead of modifying the currently existing GazeAction script, let's create a new script called GazePopup in the Scripts folder. We will create a public variable textBoxPrefab of type GameObject to point to the prefab we previously created. We will also create a private variable textBox of type GameObject. This will hold the cloned instantiation of the prefab. This is necessary because we need to make this textbox disappear once the user moves her gaze away from the hologram. Unity does not allow the actual prefab asset to be destroyed (I learnt this the hard way!)<br /><br />I wanted the text popup to appear whenever the user gazed at the hologram so I put the popup instantiation code in the OnFocusEnter function. I positioned it to appear an x-offset away from the object itself. <br /><br />Once the user looks away from the hologram, you need to delete the text popup. This can be done by calling the Destroy method on the cloned instantiation textBox. <br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/gazepopupscript_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><em>Pro Tip: </em>Notice how the text popup appears conditionally based on the textPopup boolean value? This is because we don't want to create multiple copies of the prefab in our scene. Take out the if condition and see what happens<br /><br /><em>Pro Tip 2: </em>To see a richer font quality, increase the size of the font in the prefab and scaling it down. Trial and error will get you the right answer<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/gazepopup-final_1_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>]]></content:encoded></item><item><title><![CDATA[Hololens in Hollywood!]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/hololens-in-hollywood]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/hololens-in-hollywood#comments]]></comments><pubDate>Wed, 21 Mar 2018 06:46:26 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/hololens-in-hollywood</guid><description><![CDATA[Short note but exciting news! The Hololens was used during the making of the new Steven Spielberg movie, Ready Player One. A number of VR and MR headsets were used to recreate the Oasis network (really well described in the book as well). I'm stoked to read this, super excited to watch the movie, and highly recommend the 2011 book by Ernest Cline as well.  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Short note but exciting news! The Hololens was used during the <a href="https://uploadvr.com/ready-player-one-used-rift-dk2-vive-hololens-virtual-production/" target="_blank">making of the new Steven Spielberg movie</a>, Ready Player One. A number of VR and MR headsets were used to recreate the Oasis network (really well described in the book as well). I'm stoked to read this, super excited to watch the movie, and highly recommend the 2011 book by Ernest Cline as well. <br /></div>]]></content:encoded></item><item><title><![CDATA[Airtap support for your applications]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/airtap-support-for-your-applications]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/airtap-support-for-your-applications#comments]]></comments><pubDate>Mon, 14 Aug 2017 02:37:04 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/airtap-support-for-your-applications</guid><description><![CDATA[&nbsp;In this post, we will go over how to implement and support airtap gestures for your application. The airtap gesture is the simplest select gesture performed on the Hololens. More on gestures can be found here.      Configuring for airtap in UnityThis is one of the easier gestures to implement in Unity because we have already incorporated the InputManager. InputManager includes GesturesInput which contains scripts to detect hand gestures.If you hit play in Unity, you will notice two hands t [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">&nbsp;In this post, we will go over how to implement and support airtap gestures for your application. The airtap gesture is the simplest <strong>select</strong> gesture performed on the Hololens. More on gestures can be found <a href="https://developer.microsoft.com/en-us/windows/mixed-reality/gestures" target="_blank">here</a>.</div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><br /><br /><strong><u>Configuring for airtap in Unity</u></strong><br />This is one of the easier gestures to implement in Unity because we have already incorporated the InputManager. InputManager includes GesturesInput which contains scripts to detect hand gestures.<br /><br />If you hit play in Unity, you will notice two hands that show up in the Game mode. This indicates that your application is already configured to accept tap, hold, and manipulation gestures. The left hand is selected by holding the left Shift key and the right hand by the Spacebar. Once a hand is selected, click using the left mouse button.<br /><br /><strong><u>Creating a script to listen to gestures</u></strong><br />Once again, in Assets&rarr;Scripts, create a new script and name it GestureAction. Open it in VS17.<br />This script imports from IInputClickHandler and requires a function OnInputClicked(InputClickedEventData eventData).<br /><br />For this example, we will randomize the color of our sphere anytime the user performs an airtap gesture. Each game object has a Color component, accessed using GetComponent&lt;Renderer&gt;.material.color.<br />A new <a href="https://docs.unity3d.com/ScriptReference/Color.html" target="_blank">Color </a>can be created on initialization by calling its constructor. A color is defined with 4 floats; components r,g, and b define the RGB space and alpha defines the transparency. We will randomize RGB and use 1.0 for alpha.<br />The complete code is shown below.<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/gesturescript_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><strong><u>Test the script</u></strong><br />Attach this script to the sphere in Unity. Hit play and test it. Does the color change?<br /><br />Probably not. Don't panic! This makes complete sense. The Gaze functionality we developed forces the sphere's color (in my case, to blue). This overwrites any actions performed by the Gesture script. In the Inspector window for the sphere, disable Gaze Action and try it again. It should work this time round. The color of the sphere should randomize every time you click. Try it with both the "left" and "right" hand.<br /><br /><u><strong>Fix the Gaze Script (optional)</strong></u><br />We clearly don't want the Gaze and Gesture script to conflict. Instead of changing the color on gaze, we can change the metallic level of the object. Without going into too much detail, here's the code to do that in the GazeScript script. <br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/modifiedgazescript_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>]]></content:encoded></item><item><title><![CDATA[Adding voice commands]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/adding-voice-commands]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/adding-voice-commands#comments]]></comments><pubDate>Sun, 13 Aug 2017 03:38:47 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/adding-voice-commands</guid><description><![CDATA[Another way to interact with your holograms is via voice commands. Hololens supports a variety of voice commands with the help of Cortana. Apart from the standard commands, you can program your own keywords to specify certain interactions with holographic objects.      Create a new Speech ManagerThe first thing to do here is create a new empty object in the Hierarchy under Managers and name it SpeechManager.Search for the SpeechInputSource script in Assets and drag it into this new object. For t [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Another way to interact with your holograms is via voice commands. Hololens supports a <a href="https://support.microsoft.com/en-us/help/12647/hololens-use-your-voice-with-hololens" target="_blank">variety of voice commands</a> with the help of Cortana. Apart from the standard commands, you can program your own keywords to specify certain interactions with holographic objects.</div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><br /><br /><u><strong>Create a new Speech Manager</strong></u><br />The first thing to do here is create a new empty object in the Hierarchy under Managers and name it SpeechManager.<br /><br />Search for the SpeechInputSource script in Assets and drag it into this new object. For this example, we are going to change the size of the sphere by either a) Increasing size b) Decreasing size or c) Going back to default size.<br /><br />In the Inspector window of the SpeechManager object, expand the Keywords menu under Speech Input Source. Let's add some keywords that our application can recognize. Click the + button and add 3 keywords: Increase size, Decrease size, Default size. I also added some options under Key Shortcut to allow us to test the speech recognition script that we will develop through Unity<br /><br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/speechinspector.png?1502602289" alt="Picture" style="width:199;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><u><strong>Create a script to recognize keywords</strong></u><br />This step involves creating a new C# script to perform certain tasks on the sphere once a voice command from the list created above is recognized.<br />Under Assets&rarr;Scripts, create a new C# script and name it SpeechAction. Open it in VS 2017. The SpeechInputSource script inherits from ISpeechHandler. Similar to what we did for Gaze, our new script will also inherit from ISpeechHandler and, in the header, we will add the command <em>using HoloToolkit.Unity.InputModule </em>to import this functionality.&nbsp;<br />The function that is inherited is OnSpeechKeywordRecognized(SpeechKeywordRecognizedEventData eventData<br /><br />Whenever a voice command is issued while gazing at the holographic object, this function is called. Within this function, we can parse the input and, based on what the user has said, we can call the appropriate sizing function on the object.<br /><br />The code snippet to parse the input is shown in the screenshot below, but first let's discuss how to change the size of the object. The object has a transform component that has a Vector3 localScale parameter. This represents the size of the object in x, y, and z.<br /><br />To change the size of the object, we have to simply manipulate this parameter. We can create two <a href="https://docs.unity3d.com/ScriptReference/SerializeField.html" target="_blank">SerializeFields </a>that hold scaling factors for increasing and decreasing the object. These values can be manipulated from the sphere's inspector window once this script is attached to it.<br /><br /><em>Pro Tip: </em>You generally shouldn't need to use SerializeFields. For public variables, Unity automatically serializes them in the object's Inspector window. Using SerializeFields for private variables will also show them in the Inspector window. <br /><br />In order to remember the default object size, we can save this parameter to a private variable in the void Start() function, which is called at the beginning only, during object creation.<br /><br />The complete script is shown below. Remember to drag it to the sphere to attach it.<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/speechscript_1_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><strong><u>Testing the Script</u></strong><br />Hit play in Unity to test the script. If you do not have a microphone configured to receive input in Unity (I don't) you can use the key shortcuts instead. In my project, 0 = Increase size, 1 = Decrease size, and 2 = Default size.<br /><br />This simple example hopefully shows how voice commands can be used to interact with your holograms. Try something else like changing the color of the object instead, by assigning a new color to gameObject.GetComponent&lt;Renderer&gt;().material.color.<br /></div>]]></content:encoded></item><item><title><![CDATA[Deploying your app to the Hololens]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/deploying-your-app-to-the-hololens]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/deploying-your-app-to-the-hololens#comments]]></comments><pubDate>Sun, 06 Aug 2017 02:03:05 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/deploying-your-app-to-the-hololens</guid><description><![CDATA[Now that we have successfully created our first Hololens application, we need to load it onto the Hololens and try it out real time. There are various steps in this process, starting from applying settings in Unity to building the application onto the device using Visual Studio.      Getting the project ready in UnityUnder the HoloToolkit menu, click Configure&rarr;Apply Hololens Project Settings. A popup menu will display a list of selectable settings. Select all of them and hit Apply.Unity wil [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Now that we have successfully created our first Hololens application, we need to load it onto the Hololens and try it out real time. There are various steps in this process, starting from applying settings in Unity to building the application onto the device using Visual Studio.<br /></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><br /><strong><u>Getting the project ready in Unity</u></strong><br /><br />Under the HoloToolkit menu, click Configure&rarr;Apply Hololens Project Settings. A popup menu will display a list of selectable settings. Select all of them and hit Apply.<br />Unity will prompt you to reload your project in order for the changes to take effect. This is a one-time thing for any new project.<br /><br />Once Unity has restarted, click File&rarr;Build Settings. Click on Add Open Scenes to add your main scene to the build menu. Make sure that the platform selected is Universal Windows Platform. The settings in the image below are what you need:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/project-build-settings.png?1501985562" alt="Picture" style="width:414;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Before we click Build, click on Player Settings.<br />In the Inspector menu, click Publishing Settings&rarr;Capabilities. Make sure Microphone, SpatialPerception, and Bluetooth (in case you are using the Clicker accessory) are selected.<br />In the Inspector menu, click Other Settings. Make sure Virtual Reality Supported is selected and Windows Holographic shows up under Virtual Reality SDKs.<br /><br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/othersettings.png?1501985798" alt="Picture" style="width:318;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now we are ready to click Build in the Build Settings window. A File Explorer window will popup, prompting you to save the build location. The consensus here seems to be to create a new folder called App and selecting this folder for your build.<br /><br /><u><strong>Connecting to your Hololens</strong></u><br />The first thing to do when turning on and logging into your Hololens is to enable developers mode. Go to Settings&rarr;Update and Security&rarr;For developers. Turn developer mode <strong>on</strong>. This will prompt you to enter a username and password to access your device remotely.<br /><br />Under the Paired devices menu, click on Pair. This will open a prompt with a PIN that is required when first pairing with the device.<br /><br />On the same page, under Device Portal, enable remote management of the device.<br /><br />We will be deploying our Hololens app via WiFi, so go ahead and get the IP address of your device from Settings&rarr;Network and Internet&rarr;Wi-Fi. Click on Advanced Options and record your IPv4 address. Mine is 192.168.0.105.<br /><br />Make sure that your Hololens is able to talk to your PC by opening a new browser window on your PC and navigating to https://192.168.0.105 (replace this with the IPv4 address you recorded above). If all goes well, you should see this page:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/hololensconnectwebsite_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><strong><u>Deploying the application</u></strong><br /><br />The device has been paired to your PC and the project is ready for deployment. In a File Explorer menu, navigate to the App folder you created for your project and double click on the .sln file. This will open Visual Studio 2017.<br /><br />Under the menu, you will see the following deployment options:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/deployoptions_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Make sure you have selected x86 as the Solutions Platform and Remote Machine as the location of the machine you wish to deploy your app. Selecting Remote Machine will open another prompt asking you to find the Hololens device. You can either manually enter the IP address under Manual Configuration or let VS17 auto detect the device.<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/connections.png?1502123152" alt="Picture" style="width:302;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Hit the Play button for Remote Machine.<br />Deployment can take a while, depending on the size of your application. Sometimes, VS17 will prompt you to enter a PIN to establish connection with the device. Enter the PIN you saved when clicking on Pair, under settings in the Hololens. <br /><br />Once the app has been successfully deployed, VS17 will display Ready at the bottom of the screen. Enjoy!<br /></div>]]></content:encoded></item><item><title><![CDATA[Gaze 101]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/gaze-101]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/gaze-101#comments]]></comments><pubDate>Wed, 02 Aug 2017 05:03:56 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/gaze-101</guid><description><![CDATA[One of the most elegant features of the Hololens is that, basically, you are the cursor. Looking at a holographic object is equivalent to moving your mouse cursor to point.In this post, we will develop a simple script that utilizes the Gaze feature of the Hololens to perform certain actions on objects in the scene that we can interact with.      Create a ScriptThe HoloToolkit contains scripts and interfaces that allow us to use the Gaze feature of the Hololens. The interface that we will be usin [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">One of the most elegant features of the Hololens is that, basically, you are the cursor. Looking at a holographic object is equivalent to moving your mouse cursor to point.<br /><br />In this post, we will develop a simple script that utilizes the Gaze feature of the Hololens to perform certain actions on objects in the scene that we can interact with.<br /></div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><strong><u>Create a Script</u></strong><br /><br />The HoloToolkit contains scripts and interfaces that allow us to use the Gaze feature of the Hololens. The interface that we will be using is the IFocusable interface, located in HoloToolkit&rarr;Input&rarr;Scripts&rarr;InputHandlers<br /><br /><em>Pro Tip: </em>Find any script by searching for it in the search bar in the Projects window. A list of scripts included in the Mixed Reality Toolkit can be found <a href="https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/master/Assets/HoloToolkit/Input/README.md" target="_blank">here</a>. <br /><br />Let's open this up by double clicking it. It should launch Visual Studio 2017.<br />The IFocusable script contains two empty functions, <strong>OnFocusEnter </strong>and <strong>OnFocusExit</strong>. The names of these functions give it away; one will be called when we gaze on the object, and the other will be called when the gaze is removed from the object. We will leverage this script in a new script that we will create for customized gaze actions.<br /><br />Back in Unity, under Assets, create a new folder called Scripts. This is the folder where we will place all our custom scripts. In this folder, create a C# script called GazeAction. Open it in Visual Studio. The empty script should look something like this:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/shellgazescript.png?1501651042" alt="Picture" style="width:356;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In order to use the functions from IFocusable, and for the InputManager to understand how to tie the gaze action to these functions, we need to inherit it in our custom script. We also need to import an additional interface - using HoloToolkit.Unity.InputModule - to our script.<br /><br /><strong><u>Gazing at the Object</u></strong><br /><br />For this project, when we gaze at the sphere in our game, we want to change its color from Red to Blue. Create a new function public void OnFocusEnter(). In this function, we will first save the current color of the sphere. To access the color of the sphere, we need to get its Renderer component, as follows:<br /><em>var temp = this.gameObject.GetComponent&lt;Renderer&gt;( );<br /></em>Here, gameObject refers to the specific game object that this script is attached to. Refer <a href="https://docs.unity3d.com/ScriptReference/GameObject.html" target="_blank">here </a>for more information on GameObject class in Unity. <br /><br />Now, the current object color needs to be saved. Let's create a private variable in this script called originalColor. The variable is made private so that no outside function or object has access to it. The color can now be saved:<br />originalColor = temp.material.color;<br /><br />The last thing left to do is to assign the object's color to another color. We can create a public Color variable called gazeColor and initialize it to a color of choice. In my case, I assigned it to Color.blue. The object's color when gazed on can be changed as follows:<br /><em>temp.material.color = gazeColor;</em><br /><br /><u><strong>Gaze removed from Object</strong></u><br /><br />When the gaze is removed from the object, we want to assign it back to its original color. The code is similar to the above case:<br /><em>var temp = this.gameObject.GetComponent&lt;Renderer&gt;( );<br />temp.material.color = originalColor;</em><br /><br />The completed script looks like this:<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/published/completedgazescript.png?1501652227" alt="Picture" style="width:401;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><strong><u>Assign Script actions to Game Object</u></strong><br /><br />Now that the script is done and saved, we have to assign it to the sphere in our project. In Unity, drag the script onto the sphere in the Hierarchy. If you now navigate to the Inspector menu, you will see the custom script appear. There is also a field for Gaze Color since we had made that public. If you do not like the color blue, you can change it to anything else from the Inspector panel. You <strong>do not</strong> need to edit your script to change the value of a public variable.<br /><br />Try your script out by entering the game mode (by clicking Play) and moving the cursor around with the arrow keys. If the cursor is focused on the object, it should change color (turn blue in my case). If the cursor is removed from the object, it should go back to its original color (red in my case).<br /><br />That's it! You developed your first Gaze action!<br /><br /><em>Extra Credit: </em>Try changing the color of the sphere to a random color whenever the user gazes at it. Hint <a href="https://docs.unity3d.com/ScriptReference/Random.ColorHSV.html" target="_blank">here</a><br /></div>]]></content:encoded></item><item><title><![CDATA[The First Hologram]]></title><link><![CDATA[http://www.mustansirmukadam.com/hololens/the-first-hologram]]></link><comments><![CDATA[http://www.mustansirmukadam.com/hololens/the-first-hologram#comments]]></comments><pubDate>Tue, 01 Aug 2017 22:14:42 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.mustansirmukadam.com/hololens/the-first-hologram</guid><description><![CDATA[Now that the project environment is ready for holographic development, we can design our first hologram. We will start out with something really simple and aim to build from this.      Create a sphereIn Hierarchy, under the Create menu, create a 3D Object &rarr; Sphere. You should see a sphere show up in your Scene.The sphere appears right on top of the camera. If you switch to the Game view, you won't be able to see the sphere. We can fix that by moving the sphere out in the z direction in one  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Now that the project environment is ready for holographic development, we can design our first hologram. We will start out with something really simple and aim to build from this.</div>  <div>  <!--BLOG_SUMMARY_END--></div>  <div class="paragraph"><br /><br /><strong><u>Create a sphere</u></strong><br /><br />In Hierarchy, under the Create menu, create a 3D Object &rarr; Sphere. You should see a sphere show up in your Scene.<br />The sphere appears right on top of the camera. If you switch to the Game view, you won't be able to see the sphere. We can fix that by moving the sphere out in the z direction in one of two ways:<br />1. Select the Sphere under the Hierarchy. Navigate to the Inspector panel and change the Z position number<br />2. In the Scene, drag the blue arrow (the Z direction arrow) away from the camera.<br /><br />The sphere should now be visible in the Game view. It may be larger than the field of view of the camera. Fix that by either moving the sphere even further out in the Z direction or by adjusting the scale values in the Inspector panel.<br />This is what my Inspector panel looked like at the end.<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/editor/spherescale.png?1501626636" alt="Picture" style="width:195;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Woohoo! We have a sphere. It's quite unattractive though. We can edit the visual attributes of this object by changing its material.<br /><br /><strong><u>Changing the Material</u></strong><br /><br />The Material class in Unity allows you to control the visual appearances of game objects. We can edit attributes of this class to change the color, shade, and texture of objects.<br /><br />In the Assets folder under Projects, create a new folder and name it Materials. In this folder, Create &rarr; Materials. Rename it to something that will better describe the look and feel of how you imagine the sphere. I named mine RedMaterial.<br /><br />With this new material selected, under the Inspector tab, use the eye-dropper tool located next to Albedo to pick a color from the color panel that pops up. Drag this material onto the sphere in the Hierarchy panel.<br /><br />At this point, your sphere should look like something similar to the image below. You can change the X and Y position to offset it further from the camera. Save the scene!<br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.mustansirmukadam.com/uploads/8/8/6/1/88615626/firstscene_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"></div>]]></content:encoded></item></channel></rss>