Table Of ContentHistory Google Daydream™ VR Cookbook
TopSicasm Keene
Tutorials
OffeBrso &s tDoenal s• Columbus • New York • San Francisco • Amsterdam • Cape Town
Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi
HigMhligehxtisco City • São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo
Settings
Support
Sign Out
HistMorayny of the designations used by manufacturers and sellers to distinguish their
products are claimed as trademarks. Where those designations appear in this book, and
Topics
the publisher was aware of a trademark claim, the designations have been printed with
initial capital letters or in all capitals.
Tutorials
All Unity screenshots are copyright © 2018 Unity Technologies. Unity has the right to
Offegrrs a&n Dte, aalsnd does hereby grant to Pearson, the rights to publish screenshots of the Unity
software UI. Images of Unity editor UI used with permission of Unity Technologies;
Highlights
UNITY, and other Unity trademarks, are registered trademarks and trademarks of
Unity Technologies and its affiliates in the US and elsewhere. All rights reserved. Other
Settings
images, content, names, or brands are proprietary of their respective owners. Neither
this work nor its author(s) are affiliated with, or endorsed or sponsored by, Unity
Support
Technologies or its affiliates.
Sign Out
Google, Lenovo, ARCore, Daydream, and Lenovo Mirage Solo are all trademarks.
The author and publisher have taken care in the preparation of this book, but make no
expressed or implied warranty of any kind and assume no responsibility for errors or
omissions. No liability is assumed for incidental or consequential damages in
connection with or arising out of the use of the information or programs contained
herein.
For information about buying this title in bulk quantities, or for special sales
opportunities (which may include electronic versions; custom cover designs; and
content particular to your business, training goals, marketing focus, or branding
interests), please contact our corporate sales department at [email protected]
or (800) 3823419.
For government sales inquiries, please contact [email protected].
For q uest ions ab out s ales o utside the U. S., please co ntact i [email protected].
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2018947161
Copyright © 2019 Pearson Education, Inc.
All rights reserved. This publication is protected by copyright, and permission must be
obtained from the publisher prior to any prohibited reproduction, storage in a retrieval
system, or transmission in any form or by any means, electronic, mechanical,
photocopying, recording, or likewise. For information regarding permissions, request
forms, and the appropriate contacts within the Pearson Education Global Rights &
Permissions Department, please visit www.pearsoned.com/permissions/.
ISBN13: 9780134845517
ISBN10: 013484551X
1 18
Acquisitions Editor Cover Designer
Malobika Chakraborty
Chuti Prasertsith
Development Editor Project Manager
Sheri Replin Suganya Karuppasamy
Managing Editor Compositor
Sandra Schroeder codemantra
Senior Project Editor
Lori Lyons
Technical Reviewer
Samuel Brewton Lee
Copy Editor
Paula Lowell
Indexer
Ken Johnson
Proofreader
Christopher Morris
Editorial Assistant
Courtney Martin
Preface
History
The mid1990s was when I first encountered virtual reality, and it was a transformative
Topics
experience. My father, a marine geologist and oceanographer, had just finished
mapping the ocean floor off the east coast of Australia with sonar. Using the data they
Tutorials
had collected and a giant Silicon Graphics computer, they were able to recreate a 3D
rendering of the ocean floor that could be projected onto a large screen. Armed with 3D
Offers & Deals
glasses and a joystick, the user could control a realtime 3D “fly through” along the
coast of Australia. I was blown away by this experience. In the mainstream at that time,
Highlights
VR was very uncommon, and AR was virtually unheard of. For most people, their only
exposure to these technologies was through their portrayal in futuristic Hollywood
Settings
movies.
Support
Skip ahead twenty years and VR is still as enchanting as it was then, but it is no longer
Signt hOeut exclusive domain of academia or Hollywood fiction. VR and AR are now low cost
and accessible to anyone with a mobile phone.
With Google’s powerful suite of AR and VR technologies, the time is ripe for fresh ideas
and largescale innovation in the VR and AR ecosystems. Over the next five years there
is set to be a new wave of focus on how these technologies can be used to help solve
realworld problems. Creators should be thinking now of ways to utilize AR/VR for
positive social change across all fields of endeavor: certainly gaming and entertainment
but also education, health care, government, and the environment. I hope this book acts
as an enabler to motivate professionals and hobbyists alike to build, not only
enchanting, but also socially responsible VR games and apps that produce a positive
impact on their users and on the world around us.
COOKBOOK
COOKBOOK
This book is designed as a cookbook of recipes to get the reader up and running with
VR/AR development as fast and as painlessly as possible. As well as this, the book
shines a light on the history, the concepts, and the design of AR/VR systems. The
recipes in most chapters start by first assembling the essential building blocks, which
are then pieced together to create something larger. You are then free to take these
building blocks and turn them into your own creation. Through this process you will
quickly learn how to do the tricky, yet essential, aspects of application development so
that you then can focus on the fun part, which is actually building your game. By the
end of the book you will have built out several endtoend applications and be
comfortable applying this knowledge to build out your own VR/AR creations.
AUDIENCE
The book is written for anyone interested in learning how to develop VR/AR games and
apps. Although foremost it is a technical book, the subject matter also will appeal to
programmers and anyone interested in or working on (or tinkering with) the AR and
VR industries; that is, software developers, game designers/developers, visual and UX
designers, UX researchers, academics, students, artists, producers, product managers,
and, not least of all, hobbyists.
Whether you are a UX professional, visual designer, or come from a different design
field altogether, this book is a great practical introduction to VR and AR. UX designers
and researchers will learn how to build highfidelity prototypes for evaluation of
hypotheses and the validation of designs. As well, they will also learn conceptual
information: UX, humancentered design; best practices; and tips, tricks, and insights
from my professional experience. These constitute universal themes that apply not only
to Google’s products but to all of those in VR and AR.
Software engineers and game developers with preexisting programming knowledge will
find this book indepth enough to be a beneficial resource and focused enough to
quickly ramp up in Google’s VR/AR platforms. If you are experienced with Unity, C#,
or another programming language or game development platform, it will be a bonus
but it is not essential. I cover every step in sufficient detail that beginners will be
creating endtoend games and apps in no time. For advanced developers this book is
fast paced enough and sufficiently packed with enough knowledge to keep you
interested.
People on the production, management, and accounts side of the product team with
experience in managing mobile or websbased projects will find this book insightful.
Running teams of AR/VR developers and designers require specific domain knowledge
and an understanding of the full panoply of the product pipeline in the breadth in
which this book lays out.
For students, casual creators, and hobbyists with little programming experience but
who really want to build some AR or VR games for fun in their spare time, this is the
perfect book. They will gain a clear and working introduction of the technology,
specificities of the limitations, and, by the end, will have built some entertaining games
and apps.
PREREQUISITES
To follow along with the recipes in this book you will need a copy of Unity
(https://store.unity.com/). If you do not already have Unity, a free license is available
for personal use (beginners, students, hobbyists). Check the Unity website for more
details. Be sure also to download the supplementary material for this book as most of
the recipes build on these as a starting point.
For Daydream development, you will need either:
1
A Daydreamready Android phone and a Daydream View headset
2
Or a standalone headset
See Chapters 1 and 2 for more information on the Daydream platform, available
headsets, and on setting up a Daydream development environment.
For ARCore development, you will need an ARCoreenabled Android phone running at
3
least Android 7.0 (Nougat). All the recipes in this book were built and tested using a
Google Pixel XL phone. See Chapters 1 and 7 for more information on ARCore and
getting things set up in Unity for AR development.
BENEFIT TO THE READER
The content and recipes from this book solve realworld, professional VR and AR
problems. The recipes and insights presented come directly from my professional
experience working as a UX engineer at Google on largescale AR and VR projects.
AR and VR present complex and tricky problems that novices and people unfamiliar
with the technologies often find too intimidating to pursue. This book’s aim is to assist
and motivate people to continue by propelling them over these early VR humps and
arming them with enough tips and tricks to feel comfortable to begin building their own
applications.
EXPLANATION OF ORGANIZATION
The book covers two general areas: Daydream VR and ARCore. Chapter 1 introduces
the two platforms and places them in an historical context of media history. Chapters 2
through 6 concentrate on Daydream VR development, and Chapters 7 through 9
focus on ARCore. Chapter 10 covers optimization.
The chapters are set out in such a way as to gradually introduce concepts that build on
each other over time. Frequently, these programming concepts rely on knowledge
learned from the previous chapters. However, it is not absolutely necessary to follow
the chapters in numerical order. Each chapter stands on its own and all steps are
described in detail for every recipe.
The chapters start with an indepth introduction to the topic of discussion focusing on
highlevel concepts that encapsulate the core discipline under examination. These
concepts are then applied to Unity, Daydream, and ARCore as key technical approaches
are introduced. The chapters then jump into as many useful examples as possible. Each
recipe builds on a previous one, and most require the supplementary material as a
starting point.
TOPICS COVERED IN THIS BOOK
This book is divided into 10 chapters. Chapter 1 serves as an introduction, Chapters 2
through 6 focus on Daydream VR, Chapters 7 through 9 focus on ARCore, and
Chapter 10 covers optimization.
Chapter 1, “VR and AR”: This chapter introduces Google’s VR and AR platforms
and places them in an historical context.
Chapter 2, “Daydream and Unity”: This chapter introduces you to Unity,
getting Unity set up, getting your Daydream developer environment set, up as well
as installing the Daydream SDK and the Elements Unity package. You then build a
template Unity scene to use as the starting point for all the book’s VR recipes.
Chapter 3, “Getting to Know the Daydream Controller”: The controller is
arguably one of the most important things for a Daydream developer to know about.
This chapter takes you through absolutely everything you need to know about
programming with the controller: from tapping into the various sensors, to using
the event system to grab and toss objects in 3D space.
Chapter 4, “Building UI in VR”: This chapter introduces fundamental
interaction design principles. These are important design considerations that
should to be taken into account when building useable user interfaces in VR. The
chapter takes you step by step from the very basics of using the Unity UI system all
the way through to creating a complex UI system that scrolls with the pointer and
asynchronously loads the games levels into a scene.
Chapter 5, “Video and Audio”: The video and audio chapter attempts to
demystify much of the complexity around video in VR. It starts by building a simple
rectangular video player, going through all the different types of possible video
players: 360, stereoscopic, monoscopic, and streaming. The video section ends with
a recipe that creates a video player that can dynamically switch between any type of
video being presented, all loaded in from a JSON file. The audio section introduces
the user to various considerations around audio in VR by showing how to build out
several spatialized audio recipes.
Chapter 6, “Physics Games”: No developer’s knowledge of Unity and VR is
complete without knowing how to build physicsbased games. This chapter
introduces Unity’s powerful physics engine by providing steps for building a
whimsical pancakeflipping game, then moves onto some basic weapon mechanics
for shooting games, and finally provides steps for building out an endtoend alien
pop cap game.
Chapter 7, “ARCore”: This chapter introduces everything that you need to know
about ARCore: installing it; setting up your development environment; and some
essential tips, tricks, and recipes that you’ll be using as boilerplate code for all of
your AR apps moving forward.
Chapter 8, “AR Apps”: This chapter reinforces the importance of building AR
apps that focus on solving real user needs. It starts by building a drawing app that
lets users draw with their phone in threedimensional space. The chapter then
shows the user how to use Google’s Poly Toolkit for Unity, a repository for
developers to download 3D models into their games and apps. You then use the
Poly Toolkit and Poly API to build a cataloguestyle app that places furniture in the
user’s room.