logo资料库

learning virtual reality.pdf

第1页 / 共338页
第2页 / 共338页
第3页 / 共338页
第4页 / 共338页
第5页 / 共338页
第6页 / 共338页
第7页 / 共338页
第8页 / 共338页
资料共338页,剩余部分请下载后查看
Preface
Audience
How This Book Is Organized
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
1. Introduction
What Is Virtual Reality?
Stereoscopic Displays
Motion Tracking Hardware
Input Devices
Computing Platforms
Native software development kits (SDKs)
Game engines and frameworks
Web browsers
Video players
Virtual Reality Applications
Chapter Summary
2. Virtual Reality Hardware
Oculus Rift
The DK1
The DK2
Crescent Bay
Setting Up Your Oculus Rift
Downloading the Oculus runtime, examples, and SDK
Other High-End Head-Mounted Displays
Samsung Gear VR: Deluxe, Portable Virtual Reality
The Oculus Mobile SDK
Google Cardboard: Low-Cost VR for Smartphones
Stereo Rendering and Head Tracking with Cardboard VR
Cardboard VR Input
Developing for Google Cardboard
VR Input Devices
Chapter Summary
3. Going Native: Developing for Oculus Rift on the Desktop
3D Graphics Basics
3D Coordinate Systems
Meshes, Polygons, and Vertices
Materials, Textures, and Lights
Transforms and Matrices
Cameras, Perspective, Viewports, and Projections
Stereoscopic Rendering
Unity3D: The Game Engine for the Common Man
Setting Up the Oculus SDK
Setting Up Your Unity Environment for Oculus Development
Building Your First VR Example
Building and Running the Application
Walking Through the Code
Chapter Summary
4. Going Mobile: Developing for Gear VR
The Gear VR User Interface and Oculus Home
Using the Oculus Mobile SDK
Setting Up the Android SDK
Generating an Oculus Signature File
Setting Up Your Device for USB Debugging
Developing for Gear VR Using Unity3D
Setting Up Your Unity3D Environment
A Simple Unity3D Sample
Handling Touchpad Events
Deploying Applications for Gear VR
Chapter Summary
5. WebVR: Browser-Based Virtual Reality in HTML5
The Story of WebVR
The WebVR API
Supported Browsers and Devices
Querying for VR Devices
Setting Up VR Fullscreen Mode
Head Tracking
Creating a WebVR Application
Three.js: A JavaScript 3D Engine
A Full Example
Setting up the project
The web page
The JavaScript code
Tools and Techniques for Creating Web VR
WebVR Engines and Development Tools
Using Unity3D and Unreal for WebVR Development
Open Source Libraries and Frameworks
WebVR and the Future of Web Browsing
Chapter Summary
6. VR Everywhere: Google Cardboard for Low-Cost Mobile Virtual Reality
Cardboard Basics
Supported Devices and Operating Systems
Headset Manufacturers
Other drop-in virtual reality headsets
Cardboard Applications
Input Devices for Cardboard
Cardboard Stereo Rendering and Head Tracking
Developing with the Cardboard SDK for Android
Setting Up the Environment
Walking Through the Code
Creating and rendering a stereo view
Selecting objects using gaze tracking
Detecting input from the magnet switch
Developing with the Cardboard SDK for Unity
Setting Up the SDK
Building Treasure Hunt for Unity
A Walkthrough of the Unity Code
Developing Cardboard Applications Using HTML5 and a Mobile Browser
Setting Up the WebVR Project
The JavaScript Cardboard Code
Chapter Summary
7. Your First VR Application
About 360-Degree Panoramas
Setting Up the Project
Getting the Software, Hardware, and Sample Code
Creating the Unity Scene and Project
Creating a panoramic background
Rendering back faces
Adding Cardboard VR Support
Creating a Gaze-and-Tap User Interface
Creating a 2D Plane
Adding Input Support to the Project
Creating an Event Handler Script
Handling Magnet Switch Events
Creating the Functioning User Interface
Where to Take the Project from Here
Chapter Summary
A. Resources
Headsets, Input Devices, and Video Capture Systems
Headsets
High-end head-mounted displays for desktops and consoles
Mobile HMDs
Input Devices
360 Video
Applications and Content
Flagship Experiences
Noteworthy Companies
Download Sites
WebVR Showcases and Applications
SDKs, Development Tools, and Programming Languages
Device SDKs
Game Engine Middleware
Programming Languages
Software Frameworks
Websites
Meetup Groups
Index
2
Learning Virtual Reality Developing Immersive Experiences and Applications for Desktop, Web, and Mobile Tony Parisi 3
Learning Virtual Reality by Tony Parisi Copyright © 2016 Tony Parisi. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Editors: Simon St.Laurent and Meg Foley Production Editor: Colleen Lobner Copyeditor: Rachel Head Proofreader: Charles Roumeliotis Indexer: Ellen Troutman-Zaig Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Rebecca Demarest November 2015: First Edition 4
Revision History for the First Edition 2015-10-22: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491922835 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Learning Virtual Reality, the cover image of a Salvin’s prion, and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-49192283-5 [LSI] 5
Preface Virtual reality has captured the world’s imagination. Over the last few years, developers and enthusiasts in the thousands have devoted countless hours to coding, designing, and speculating about the possibilities of this exciting new medium. Affordable hardware systems like the Oculus Rift, Samsung Gear VR, and Google Cardboard VR allow consumers to experience virtual reality firsthand in the comfort of their homes, in a cafe, or on the train to work. Press coverage has reached beyond the trade press and blogosphere to mainstream publications extolling the virtues of VR, and the possibilities seem endless: from gaming and cinema to architecture, education, training, and medicine. Even though it has a long way to go, virtual reality appears poised to become the next major entertainment medium, and perhaps even the computing platform of the future. I first tried an Oculus Rift in the summer of 2013. I was, to put it bluntly, underwhelmed. The graphics of the original development kit (the so-called “DK1”) were low-res by today’s standards, and I lasted about 10 minutes before the nausea kicked in — which, according to my friend Dave, was an impressive display of endurance. I put the device aside, grumbled “not ready,” staggered back to work, and didn’t give the matter much thought again until nine months later, when the tech industry was set on its ear by the announcement that social media giant Facebook had acquired Oculus VR, the makers of the Rift. Like many of my peers, I was stunned. Also, like many of my peers, I decided to jump right in and start developing something in VR. Since the watershed Oculus acquisition, the industry has invested millions in developing applications, content, tools, display hardware, video capture systems, and peripherals. Big tech players are already staking out their turf, making bets on what the future will look like with respect to distribution channels, “killer apps,” and such, and creating platforms and ecosystems to align with their visions. Developers of all shapes and sizes are flocking to VR, some out of genuine excitement for a new medium with great potential, and 6
others preparing to take advantage of what could be the next tech boom after mobile. However it all ultimately shakes out, being a VR developer promises to be an exciting ride. Every journey begins with a first step, and this book is here to set you on your path. It’s not deep; the goal is to familiarize you with core programming concepts, and the innovations in hardware and software that have made VR possible. It is broad: we cover three of the major platforms, using three different development environments and as many programming languages. By the end, you should come away with the feeling that you understand the basics, and a desire to learn more. 7
Audience This book was written for programmers and designers looking for an introduction to virtual reality development. It assumes at least entry-level programming experience, but you don’t have to be a professional developer to read it. Creative coders, producers with a programming background, and technically savvy artists should also be able to follow along. I want anyone who likes to make things on a computer to be able to walk away having learned something from this book. Readers should know the basics of JavaScript, Java, C#, or another C-family programming language. Experience with 3D graphics is also helpful. If you don’t have 3D experience, Chapter 3 contains a primer that you may find useful. If you are a professional developer, a lot of this material will seem basic to you. But go through it carefully: interleaved with the how-tos and 101s are essential nuggets of technical information for putting together desktop, mobile, and web VR apps. It represents many hours of carefully working through the details of various tools, SDKs, APIs, and operating systems, including suffering through a few major upgrades that were sprung on me halfway through writing the manuscript. Maybe my effort will help save you from hitting those same land mines along the way. If you are a native developer of mobile and desktop apps, and know Unity3D or another game engine, then this book should help you extend your skills into VR. If you are comfortable developing for WebGL, then you should have an easy time creating VR for the Web with the introduction of just a few new concepts. If you are a newbie at both, no worries; I like to think I wrote the book in a way that will get you going, no matter your starting point. 8
分享到:
收藏