Cardboard VR Projects for Android
eBook - ePub

Cardboard VR Projects for Android

  1. 386 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Cardboard VR Projects for Android

Book details
Book preview
Table of contents
Citations

About This Book

Develop mobile virtual reality apps using the native Google Cardboard SDK for Android

About This Book

  • Learn how to build practical applications for Google's popular DIY VR headset
  • Build a reusable VR graphics engine on top of the Cardboard Java SDK and OpenGL ES graphics libraries
  • The projects in this book will showcase a different aspect of Cardboard development—from 3D rendering to handling user input

Who This Book Is For

The book is for established Android developers with a good knowledge level of Java. No prior OpenGL or graphics knowledge is required. No prior experience with Google Cardboard is expected, but those who are familiar with Cardboard and are looking for projects to expand their knowledge can also benefit from this book.

What You Will Learn

  • Build Google Cardboard virtual reality applications
  • Explore the ins and outs of the Cardboard SDK Java classes and interfaces, and apply them to practical VR projects
  • Employ Android Studio, Android SDK, and the Java language in a straightforward manner
  • Discover and use software development and Android best practices for mobile and Cardboard applications, including considerations for memory management and battery life
  • Implement user interface techniques for menus and gaze-based selection within VR
  • Utilize the science, psychology, mathematics, and technology behind virtual reality, especially those pertinent to mobile Cardboard VR experiences
  • Understand Cardboard VR best practices including those promoted by Google Design Lab.

In Detail

Google Cardboard is a low-cost, entry-level media platform through which you can experience virtual reality and virtual 3D environments. Its applications are as broad and varied as mobile smartphone applications themselves. This book will educate you on the best practices and methodology needed to build effective, stable, and performant mobile VR applications.

In this book, we begin by defining virtual reality (VR) and how Google Cardboard fits into the larger VR and Android ecosystem. We introduce the underlying scientific and technical principles behind VR, including geometry, optics, rendering, and mobile software architecture. We start with a simple example app that ensures your environment is properly set up to write, build, and run the app. Then we develop a reusable VR graphics engine that you can build upon. And from then on, each chapter is a self-contained project where you will build an example from a different genre of application, including a 360 degree photo viewer, an educational simulation of our solar system, a 3D model viewer, and a music visualizer.

Given the recent updates that were rolled out at Google I/O 2016, the authors of Cardboard VR Projects for Android have collated some technical notes to help you execute the projects in this book with Google VR Cardboard Java SDK 0.8, released in May 2016. Refer to the article at https://www.packtpub.com/sites/default/files/downloads/GoogleVRUpdateGuideforCardbook.pdf which explains the updates to the source code of the projects.

Style and approach

This project based guide is written in a tutorial-style project format, where you will learn by doing. It is accompanied by in-depth explanations and discussions of various technologies, and provides best practices and techniques.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Cardboard VR Projects for Android by Jonathan Linowes, Matt Schoen in PDF and/or ePUB format, as well as other popular books in Informatique & Matériel. We have over one million books available in our catalogue for you to explore.

Information

Year
2016
ISBN
9781785887871
Edition
1
Subtopic
Matériel

Cardboard VR Projects for Android


Table of Contents

Cardboard VR Projects for Android
Credits
About the Authors
About the Reviewers
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Virtual Reality for Everyone
Why is it called Cardboard?
The spectrum of VR devices
Old fashioned stereoscopes
Cardboard is mobile VR
Desktop VR and beyond
A gateway to VR
The value of low-end VR
Cardware!
Configuring your Cardboard viewer
Developing apps for Cardboard
Using Unity
Going native
An overview to VR best practices
Summary
2. The Skeleton Cardboard Project
What's in an Android app?
APK files
A Gradle build process
A Java compiler
The Android project structure
Getting started with Android Studio
Installing Android Studio
The Android Studio user interface
Creating a new Cardboard project
Adding the Cardboard Java SDK
The AndroidManifest.xml file
The activity_main.xml file
The MainActivity class
Default onCreate
Building and running
Summary
3. Cardboard Box
Creating a new project
Hello, triangle!
Introducing geometry
Triangle variables
onSurfaceCreated
Introducing OpenGL ES 2.0
Simple shaders
The compileShaders method
The prepareRenderingTriangle method
onDrawEye
Building and running
3D camera, perspective, and head rotation
Welcome to the matrix
The MVP vertex shader
Setting up the perspective viewing matrices
Render in perspective
Building and running
Repositioning the triangle
Hello, cube!
The cube model data
Cube code
Lighting and shading
Adding shaders
Cube normals and colors
Preparing the vertex buffers
Preparing the shaders
Adding a light source
Building and running the app
Spinning the cube
Hello, floor!
Shaders
Floor model data
Variables
onCreate
onSurfaceCreated
initializeScene
prepareRenderingFloor
onDrawEye
drawFloor
Hey, look at this!
The isLookingAtObject method
Summary
4. Launcher Lobby
Creating a new project
Adding Hello Virtual World text overlay
A simple text overlay
Center the text using a child view
Create stereoscopic views for each eye
Controlling the overlay view from MainActivity
Using a virtual screen
Responding to head look
Adding an icon to the view
Listing installed Cardboard apps
Queries for Cardboard apps
Create the Shortcut class for apps
Add shortcuts to OverlayView
Using view lists in OverlayEye
Highlighting the current shortcut
Using the trigger to pick and launch the app
Further enhancements
Summary
5. RenderBox Engine
Introducing RenderBox – a graphics engine
Creating a new project
Creating the RenderBox package folder
Creating an empty RenderBox class
Adding the IRenderBox interface
Materials, textures, and shaders
Abstract material
The Math package
MathUtils
Matrix4
Quaternion
Vector2
Vector3
The Transform class
Parent methods
Position methods
Rotation methods
Scale methods
Transform to matrix and draw
The Component class
The RenderObject component
The Cube RenderObject component
Vertex color material and shaders
Vertex color shaders
VertexColorMaterial
The Camera component
RenderBox methods
A simple box scene
Cube with face normals
The Light component
Vertex color lighting material and shaders
Time for animation
Detect looking at objects
Exporting the RenderBox package
Building the RenderBoxLib module
The RenderBox test app
Using RenderBox in future projects
Summary
6. Solar System
Setting up a new project
Creating a Sphere component
A solid color lighted sphere
Solid color lighting shaders
Solid color lighting material
Adding a Material to a Sphere
Viewing the Sphere
Adding the Earth texture material
Loading a texture file
Diffuse lighting shaders
Diffuse lighting material
Adding diffuse lighting texture to a Sphere component
Viewing the Earth
Changing the camera position
Day and night material
Day/night shader
The DayNightMaterial class
Rendering with day/night
Creating the Sun
Unlit texture shaders
Unlit texture material
Rendering with an unlit texture
Adding the Sun
Creating a Planet class
Formation of the Solar System
Setting up planets in MainActivity
Camera's planet view
Animating the heavenly bodies
A starry sky dome
Fine tuning the Earth
The night texture
Axis tilt and wobble
Changing the camera location
Possible enhancements
Updating the RenderBox library
Summary
7. 360-Degree Gallery
Setting up the new project
Viewing a 360-degree photo
Viewing a sample photosphere
Using the background image
Viewing a regular photo
Defining the Plane component and allocating buffers
Adding materials to the Plane component
Adding an image screen to the scene
Putting a border frame on the image
Border shaders
The border material
Using the border material
Loading and displaying a photo image
Defining the image class
Reading images into the app
Image load texture
Showing an image on the screen
Rotating to the correct orientation
Dimensions to correct the width and height
Sample image down to size
Loading and displaying a photosphere image
The image gallery user interface
Positioning the photo screen on the left
Displaying thumbnails in a grid
The thumbnail image
The Thumbnail class
The thumbnail grid
Gaze to load
Gaze-based highlights
Selecting and showing photos
Queue events
Using a vibrator
Enable scrolling
Creating the Triangle component
Adding triangles to the UI
Interacting with the scroll buttons
Implementing the scrolling method
Stay responsive and use threads
An explanation of threading and virtual reality
Launch with an intent
Showing/hiding the grid with tilt-up gestures
Spherical thumbnails
Add a sphere to the Thumbnail class
Updating the RenderBox library
Further possible enhancements
Summary
8. 3D Model Viewer
Setting up a new project
Understanding the OBJ file format
Creating the ModelObject class
Parse OBJ models
buildBuffers
Model extents, scaling, and center
I'm a little teapot
I'm a little rotating teapot
Thread safe
Launch with intent
Practical and production ready
Summary
9. Music Visualizer
Setting up a new project
Capturing audio data
A VisualizerBox architecture
Waveform data capture
A basic geometric visualization
2D texture-based visualization
Texture generator and loader
Waveform shaders
Basic waveform material
Waveform visualization
FFT visualization
Capture the FFT audio data
FFT shaders
Basic FFT material
FFT visualization
Trippy trails mode
Multiple simultaneous visualizations
Random visualizations
Further enhancements
A community invite
Summary
Onward to the future
Index

Cardboard VR Projects for Android

Copy...

Table of contents

  1. Cardboard VR Projects for Android