Sean Ong

Beginning Windows Mixed Reality Programming

For HoloLens and Mixed Reality Headsets

Sean Ong

Tukwila, Washington, USA

Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/9781484227688 . For more detailed information, please visit http://www.apress.com/source-code .

ISBN 978-1-4842-2768-8

e-ISBN 978-1-4842-2769-5

https://doi.org/10.1007/978-1-4842-2769-5

Library of Congress Control Number: 2017949686

© Sean Ong 2017

This work is subject to copyright. All commercial rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.

Printed on acid-free paper

Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

This book is dedicated to my mother, Connie. She’s perfect. Maybe a little too perfect. If I didn’t know any better, I’d say she’s a hologram.

Introduction: The Holographic Future

Congratulations! If you’re reading this, it means that you will probably be among the very first people responsible for building the mixed reality and holographic future that will dominate the next era of computing. For decades, science fiction has promised us a future filled with holograms and virtual experiences. We are finally on the verge of a technological revolution where our digital world intertwines with physical reality. This is known as mixed reality .

Imagine a future scenario where no screens exist. Instead, when you sit down to watch TV, a holographic screen appears on your wall. Because the screen is virtual, you can resize it to be as big as you like. You could also move the screen to any other room, or have it follow you around the house. You sit down at an empty desk, and several holographic computer monitors appear, along with virtual photos, a calendar, and a notepad. You’re now ready to check your e-mail, work on a spreadsheet, and get started on a good day’s work. You no longer need to carry around a physical smartphone. Instead, a holographic screen appears in your palm when needed. Holographic computing has the potential to replace every screen, and there’s no reason to believe that it won’t.

Note

The holograms referred to in this book are digital holograms and do not operate on the same optical principles of traditional holography.

Does this sound like sci-fi technology that’s still several years away? You may be surprised to know that everything I just mentioned in this “future” scenario is completely possible (and available) today with the Microsoft HoloLens. Figure I-1 illustrates how I use the HoloLens as a virtual desk. If you had asked me about living in a holographic world a few years ago, I would have predicted that we’d see capable devices within 15 to 20 years, and that would have been optimistic. But that all changed January 2015, when Microsoft announced the HoloLens and the Windows Mixed Reality platform. It caught the tech world off guard and inspired people to think about what a true holographic future would look like.

A441101_1_En_BookFrontmatter_Fig1_HTML.jpg
Figure I-1. The HoloLens enables an empty desk (top image) to be filled with holographic computer monitors and desk decorations (bottom image)

In my previous “future scenario” example, you’ll notice that I only give examples of holographic 2D screens. To some, my examples may have sounded amazing or revolutionary. They are, in fact, dull examples that don’t adequately capture what the HoloLens and other holographic headsets can achieve. The challenge and opportunity of building experiences for these headsets is unlike anything that the technology industry has faced to date. Until now, the vast majority of software experiences have been designed for flat, two-dimensional screens. Think of televisions, smartphones, tablets, laptops, or even the flat page or screen on which you are reading this book. Video games, 3D movies, and other so-called “3D” advances over the past few years are nothing more than a glorified 2D experience we view on our flat, rectangular screens.

The Windows Mixed Reality platform breaks this status quo by allowing us to develop true three-dimensional applications in our real world. Early applications that have emerged for the HoloLens suffer from developers “thinking inside the box” by creating 2D experiences such as floating holographic screens or 2D menus and buttons for navigation. Many in the industry believe that a functional and intuitive 3D user experience has yet to be discovered and developed. As we go through the tutorials and example projects in this book, we will pay particular attention to 3D design elements while discussing ways to think outside the box and move beyond the 2D status quo.

It is a very exciting time to be a holographic developer. The devices are capable, the computing paradigm is new, and ideas for good applications seem to be endless. We holographic developers are the engineers, architects, and builders that will create the forthcoming holographic world.

The holographic future is inevitable. As with all high-tech gadgets, devices like the HoloLens will only become smaller and more powerful over time. I anticipate that it won’t be more than a few years until we see holographic glasses that are as thin and light as the Google Glass device that was announced in 2012. 1 It’s not hard to image a future where many (if not most) people will wear a pair of these holographic glasses, whether or not they require prescription eyewear. Being equipped with these headsets will enable us to augment physical reality with relevant information, have more immersive digital experiences, and free us from the unnecessary screens that fill up our desks, walls, pockets, and purses.

How important will holographic devices be in daily life? One could speculate that most people in the near future might not be able to participate fully in society without a pair of holographic glasses. At first, this might sound like a dystopian prediction of our future. But think about how we use computers and smartphones today. It’s very difficult to participate fully in today’s modern society if you don’t own or know how to use a computer. A vast majority of jobs in the United States require the use of a computer. We use e-mail and online messages as primary forms of communication. Surely, if you told someone 30–40 years ago that they would not be able to fully participate in a future society without owning or knowing how to use a computer, they would have been hesitant about such a future. Yet many of us today probably can’t imagine daily life without our trusty PC or smartphone. Likewise, in 20 years I think we’ll look back and wonder how we ever lived without our trusty holographic glasses.

Perhaps I’ve given you a glimpse of the future. More importantly, I hope to have inspired you to start thinking about the holographic apps and experiences that will fill the world around us. All of us are relying on people like you to build our holographic future. My motivation for writing this book is to get as many people started on holographic development as possible. It’s written to be easily accessible, whether you’re an experienced software developer or new to the world of programming. This book is intended to get you started with everything you need to begin developing amazing holographic experiences on the HoloLens and other Mixed Reality headsets.

This book is organized into ten chapters spread across three parts. In Part I, which contains Chapters 1 and 2 , you will be guided through the installation and explanation of all the necessary software and tools for developing Windows Mixed Reality applications.

Everything you need to get started is contained in Chapter 1 . You can begin developing Mixed Reality apps with or without a HoloLens. Things I cover in Chapter 1 include the following:

  • Making sure your PC is ready for Mixed Reality development

  • Using a HoloLens, HoloLens Emulator, or other Mixed Reality hardware

  • Downloading and installing the required and optional software tools

  • Understanding the HoloLens and other Windows Mixed Reality hardware

Chapter 2 dives into the basics of Unity. Unity is the preferred software platform for developing Windows Mixed Reality experiences. Things we’ll cover in Chapter 2 include the following:

  • Understanding Unity

  • Creating your first application in Unity

  • Unity and Windows Mixed Reality

In Part II, comprised of Chapters 37 ,we’ll start building holographic experiences. This is where you’re guided through the fundamentals of creating a full-featured Mixed Reality application.

You’ll learn how to make digital holograms in Chapter 3 . You’ll be guided through the creation of a basic holograms that can be viewed in the HoloLens. Here’s what Chapter 3 covers:

  • Preparing Unity for Windows Mixed Reality development

  • Creating a cube in Unity

  • Building and deploying the Unity application to the HoloLens

I discuss the HoloToolkit in Chapter 4 . Manually preparing Unity for HoloLens development can be cumbersome and prone to error. This chapter introduces the HoloToolkit and how you can leverage this community resource:

  • Understanding the HoloToolkit

  • Downloading and using the HoloToolkit

In Chapter 5 , we start interacting with holograms. I discuss the use of gestures, voice commands, and other ways of interacting with Holographic content. Here’s what I cover in Chapter 5 :

  • Voice commands

  • Gestures

  • Gaze

  • Clickers and other accessories

Things start getting interesting in Chapter 6 , where you begin to leverage the power of the HoloLens by learning about using spatial mapping. I walk you through the technology, concept, and utilization of spatial mapping in the context of holographic applications. Chapter 6 covers the following topics:

  • What is spatial mapping?

  • How to use spatial mapping in projects

  • Spatial understanding

  • Anchors and persistence

Chapter 7 talks about spatial sound. You’ll learn about the importance of spatial sound and how to utilize it in your projects. We’ll discuss the following:

  • What is spatial sound and how is it different than “regular” sound?

  • How to use spatial sound in projects

  • Best practices for spatial sound

  • Additional sound resources

Part III (Chapters 810 ) is about growing as a Mixed Reality developer. At this point in the book, you’ll be familiar with the basics of creating a Mixed Reality application. The three chapters introduce ways for you to optimize and enhance your experiences, publish and monetize your apps, and join the broader holographic community for support and visibility.

In Chapter 8 , I discuss tips and tricks for awe-inspiring experiences. This chapter provides you with a primer on elements that give holographic experiences additional flair and magic, such as color choice, ambient elements, music, size, and more. Finally, we’ll complete a capstone project together using key skills gained in this book. Here’s what’s covered in Chapter 8 :

  • Optimization and performance

  • Design

  • Magic

  • Capstone project

Let’s make some money! In Chapter 9 , I discuss the details of publishing and monetizing your applications. You’re presented with strategies for monetization, from publishing your app in the Windows Store to freelancing as an independent Mixed Reality developer. Here’s what Chapter 9 covers:

  • Monetization with the Windows Store

  • Freelancing

  • Thinking big: revolutionary opportunities

In Chapter 10 , I suggest community resources and additional information for holographic developers. This chapter introduces resources that are available to you, including relevant community forums and online groups, notable events, and other information that will help during the development process:

  • Why are community resources important?

  • The official Windows Mixed Reality forums

  • The HoloDevelopers Slack channel

  • Events and local groups

  • More information

As you embark on your journey to becoming one of the first Mixed Reality developers, I encourage you to keep two things in mind. First, always think outside the box or outside the “2D rectangle” that has dominated computing up until this point in time. Second, understand that you are responsible for building a new industry and the holographic world of tomorrow. You are a technological pioneer. Understanding this will inspire you to reach new heights and explore new ways of creating amazing experiences.

Acknowledgments

I’d like to thank Bart Trzynadlowski for his thorough technical review of this book. I also thank Dwayne Lamb and Jesse McCulloch for establishing amazing HoloLens communities from which I attribute most of the HoloLens knowledge I have gained. Finally, I want to thank Jonathan Gennick and Jill Balzano for their friendship, persistence, and editorial support.

Contents

  1. Part I: Getting Started
    1. Chapter 1:​ Gear Up:​ The Necessary Hardware and Software Tools
      1. Making Sure Your PC Is Ready
      2. Using a HoloLens, Emulator, or Other Mixed Reality Hardware
        1. Testing with the HoloLens
        2. Testing with Emulation
      3. Understanding the HoloLens and Other Windows Mixed Reality Hardware
        1. Inside-Out Tracking and Spatial Mapping
        2. Spatial Sound
        3. Transparent vs.​ Immersive Headsets
      4. Downloading and Installing the Required and Optional Software Tools
        1. Installing Visual Studio
        2. Installing Unity
        3. Downloading the HoloToolkit
      5. Summary
    2. Chapter 2:​ Unity Crash Course
      1. What Is Unity?​
        1. Free vs.​ Paid Tiers of Unity
      2. Your First Unity App
        1. Step 1:​ Create a New Unity Project
        2. Step 2:​ Save Your Scene
        3. Step 3:​ Create a Ground Plane
        4. Step 4:​ Rename Your Plane
        5. Step 5:​ Reset Ground Plane Position
        6. Step 6:​ Zoom to Your Ground Plane
        7. Step 7:​ Scale Your Ground Plane
        8. Step 8:​ Create the Ball
        9. Step 9:​ Rename Your Ball
        10. Step 10:​ Reset the Ball’s Position
        11. Step 11:​ Zoom to Your Ball
        12. Step 12:​ Raise the Ball’s Position
        13. Step 13:​ Color the Ground Blue
        14. Step 14:​ Add Physics to the Ball
        15. Step 15:​ Enable Keyboard Control
        16. Step 16:​ Testing Your App
      3. Summary
  2. Part II: Building Holographic Experiences
    1. Chapter 3:​ Creating Your First Hologram
      1. Getting Unity Ready for Mixed Reality Development
        1. Step 1:​ Import HoloToolkit to a New Unity Project
        2. Step 2:​ Use HoloToolkit to Prepare Your Scene for Mixed Reality Development
      2. Your First Hologram
        1. Step 1:​ Create a Cube
        2. Step 2:​ Zoom to Your Cube
        3. Step 3:​ Move the Cube Away from the Camera
        4. Step 4:​ Resize the Cube
        5. Step 5:​ Test Your App
        6. Step 6:​ Install Your App on the HoloLens
      3. Test Your App Using Holographic Remoting
        1. Step 1:​ Install and Run the Holographic Remoting Player to Your HoloLens
        2. Step 2:​ Connect to Your HoloLens with Unity’s Holographic Remoting
        3. Step 3:​ Test Your App Using Holographic Remoting
      4. Test Your App Using Holographic Simulation
        1. Step 1:​ Enable Holographic Simulation
        2. Step 2:​ Connect Your Controller
        3. Step 3:​ Test Your App Using Holographic Simulation
      5. Summary
    2. Chapter 4:​ Introduction to the HoloToolkit
      1. What Is the HoloToolkit?​
      2. HoloToolkit Setup
      3. HoloToolkit Components
        1. HoloToolkit:​ Input
        2. HoloToolkit:​ Sharing
        3. HoloToolkit:​ Spatial Mapping
        4. HoloToolkit:​ Spatial Understanding
        5. HoloToolkit:​ Spatial Sound
        6. HoloToolkit:​ Utilities
        7. HoloToolkit:​ Build
      4. HoloToolkit Online
        1. The Two HoloToolkit Repositories
        2. What Is GitHub?​
        3. HoloToolkit Help and Documentation
      5. Summary
    3. Chapter 5:​ Interacting with Holograms
      1. Input Methods
      2. Gaze Tutorial
        1. Step 1:​ Set Up the Unity Scene
        2. Step 2:​ Try the Scene
        3. Step 3:​ Understand the Scene
        4. Step 4:​ Use Gaze in Your Project
      3. Gestures Tutorial
        1. Step 1:​ Load the Test Scene
        2. Step 2:​ Try It Out
        3. Step 3:​ Use Air-Tap or Select Gesture
        4. Step 4:​ Enter and Exit Focus
        5. Step 5:​ Move Objects
        6. Step 6:​ Implementing Gestures in Your Application
      4. Voice Command Tutorial
        1. Step 1:​ Load the Test Scene
        2. Step 2:​ Try It Out
        3. Step 3:​ Understand the Scene
        4. Step 4:​ Add Your Own Voice Command
        5. Step 5:​ Use Voice Commands in Your Own Project
        6. Best Practices for Voice Commands
      5. Other Hardware Input
      6. Summary
    4. Chapter 6:​ Using Spatial Mapping
      1. What Is Spatial Mapping?​
      2. Spatial Mapping Tutorial
        1. Step 1:​ Set Up Unity Scene
        2. Step 2:​ Try It Out
        3. Step 3:​ Understand the Scene
        4. Step 4:​ Use Spatial Mapping in Your Application
      3. Spatial Plane Finding Tutorial
        1. Step 1:​ Set Up the Unity Scene
        2. Step 2:​ Try It Out
        3. Step 3:​ Load the Spatial Processing Scene
        4. Step 5:​ Try Out the SpatialProcessin​g Scene
        5. Step 6:​ Understand the SpatialProcessin​g Scene
        6. Step 7:​ Use Spatial Processing in Your Application
      4. Occlusion Tutorial
        1. Step 1:​ Load the TapToPlace Scene
        2. Step 2:​ Apply Occlusion
        3. Step 3:​ Try It Out
        4. Step 4:​ Use Occlusion in Your Application
      5. Spatial Understanding Tutorial
        1. Step 1:​ Set Up the Unity Scene
        2. Step 2:​ Try It Out
        3. Step 3:​ Use Spatial Understanding in Your Application
      6. Spatial Anchors and Persistence
        1. How to Use Spatial Anchors
        2. Hologram Persistence
        3. A Note on Sharing Anchors
      7. Summary
    5. Chapter 7:​ Spatial Sound
      1. Spatial Sound Tutorial
        1. Step 1:​ Set Up the Unity Scene
        2. Step 2:​ Try It Out
        3. Step 3:​ Understand the Scene
        4. Step 4:​ Enable Spatial Sound in Your Application
      2. Spatial Sound Design Considerations
        1. When to Use Spatial Sound
        2. What to Avoid When Using Spatial Sound
      3. Summary
  3. Part III: Growing as a Holographic Developer
    1. Chapter 8:​ Awe-Inspiring Experiences
      1. What Makes an App Awe-Inspiring?​
      2. Optimization and Performance
        1. How to Monitor for Performance
        2. Best Practices for Performance
        3. Simplygon
        4. Holographic Remoting
        5. Stabilization Plane
      3. Design and Magic
        1. Best Practices for Design
        2. Adding Magic:​ Vuforia
      4. Capstone Project
        1. Step 1:​ Import HoloToolkit to a New Unity Project
        2. Step 2:​ Apply HoloLens Settings
        3. Step 4:​ Insert and Configure InputManager
        4. Step 5:​ Add a Cursor
        5. Step 6:​ Create Responsive Ball
        6. Step 7:​ Download Assets
        7. Step 8:​ Create Your Lava Scene
        8. Step 9:​ Add the Ability to Move Lava Scene
        9. Step 10:​ Add and Configure Spatial Mapping
        10. Step 11:​ Add Spatial Sound Effects
        11. Step 12:​ Next Steps and Beyond
      5. Summary
    2. Chapter 9:​ Turning Holograms into Money
      1. Publishing Your App to the Windows Store
      2. Freelancing
        1. Finding Mixed Reality Freelance Opportunities
        2. Increasing Your Chances of Winning a Contract
      3. Future Opportunities Today
      4. Summary
    3. Chapter 10:​ Community Resources
      1. Microsoft’s Official Mixed Reality Forum
      2. HoloDevelopers Slack Team
        1. What Is Slack?​
        2. What Is the HoloDevelopers Slack Team?​
        3. How to Join the HoloDevelopers Slack Team
        4. Participating in the HoloDevelopers Slack Team
      3. Other Online Communities and Resources
        1. HoloLens Developers Facebook Group
        2. Unity and Unity HoloLens Forum
        3. HoloLens Subreddit
        4. Next Reality News
        5. YouTube
      4. Local Events and Meetups
        1. Europe Meetups
        2. North America Meetups
        3. Asia Pacific Meetups
      5. Hackathons
      6. Notable Industry Events
      7. Summary
  4. Index

About the Author and About the Technical Reviewer

About the Author

A441101_1_En_BookFrontmatter_Figb_HTML.jpg

Sean Ong is an author, engineer, entrepreneur, and tech influencer who has written on topics ranging from renewable energy to augmented reality. Sean’s love for virtual and augmented reality began at the age of five when he first tried the View-Master toy. Later, at the age of 14, he coded his first virtual home tour. Sean was among the first people to own a HoloLens and has developed numerous experiences for the new platform since its release. He is president of the Virtual Reality and Augmented Reality Association’s Seattle chapter and is well known in tech circles for his informative tutorials and articles that have helped over seven million people. He resides in Seattle, Washington, with his wife and three kids and enjoys pushing the boundaries of technology.

About the Technical Reviewer

A441101_1_En_BookFrontmatter_Figc_HTML.jpg

Bart Trzynadlowski has been programming since the fifth grade. After taking a detour deep into the world of semiconductor device physics and earning his PhD in electrical engineering, he presently develops low-latency software for a leading algorithmic options trading desk. Excited by the potential of Mixed Reality, Bart has been developing HoloLens apps in his spare time since June 2016.

Footnotes

1 Google Glass is a small device that projected notifications, images, and other information to a small glass display near the user’s right eye. Unlike the HoloLens, it did not place 3D holographic objects in the user’s world.

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

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