Home Page Icon
Home Page
Table of Contents for
Index
Close
Index
by Matt Schoen, Jonathan Linowes
Cardboard VR Projects for Android
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
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Onward to the future
Index
A
aapt /
A Java compiler
activity_main.xml file
about /
The activity_main.xml file
aidl tool /
A Java compiler
Android API Reference
URL /
The MainActivity class
Android app
about /
What's in an Android app?
APK files /
APK files
Gradle build process /
A Gradle build process
Java compiler /
A Java compiler
Android Asset Packaging Tool (aapt) /
A Gradle build process
Android Interface Definition Language /
A Java compiler
AndroidManifest.xml file
about /
The AndroidManifest.xml file
URL /
The AndroidManifest.xml file
Android OpenGL ES API Guide
URL /
Introducing OpenGL ES 2.0
Android project structure
about /
The Android project structure
URL /
The Android project structure
Android SDK Getting Started page
URL /
The Android Studio user interface
Android Studio
about /
Getting started with Android Studio
installing /
Installing Android Studio
developers page /
Installing Android Studio
user interface /
The Android Studio user interface
user interface, URL /
The Android Studio user interface
Android Virtual Device (AVD) /
APK files
APK files /
APK files
apps, for Cardboard
developing /
Developing apps for Cardboard
developing, Unity used /
Using Unity
,
Going native
audio data
capturing /
Capturing audio data
B
basic geometric visualization
about /
A basic geometric visualization
border frame
putting, on image /
Putting a border frame on the image
border shaders /
Border shaders
border material /
The border material
border material, using /
Using the border material
C
Camera
about /
Introducing RenderBox – a graphics engine
Camera component
about /
The Camera component
camera location
changing /
Changing the camera location
Cardboard
about /
Why is it called Cardboard?
Cardboard Android demo app
URL /
The Android Studio user interface
Cardboard apps
360 degree photo viewing /
The value of low-end VR
video and cinema viewing /
The value of low-end VR
roller coasters and thrill rides /
The value of low-end VR
cartoonish 3D games /
The value of low-end VR
first person shooter games /
The value of low-end VR
creepy scary stuff /
The value of low-end VR
educational experiences /
The value of low-end VR
marketing experiences /
The value of low-end VR
listing /
Listing installed Cardboard apps
queries /
Queries for Cardboard apps
Shortcut class, creating /
Create the Shortcut class for apps
shortcuts, adding to OverlayView /
Add shortcuts to OverlayView
view lists, using in OverlayEye /
Using view lists in OverlayEye
launching, trigger used /
Using the trigger to pick and launch the app
Cardboard devices
about /
Cardware!
Cardboard Java SDK
adding /
Adding the Cardboard Java SDK
Cardboard project
new Cardboard project, creating /
Creating a new Cardboard project
Cardboard SDK for Android
reference /
Developing apps for Cardboard
Cardboard SDK for Unity
reference /
Developing apps for Cardboard
Cardboard viewer
about /
Cardware!
configuring /
Configuring your Cardboard viewer
Cardboard VR app
new project, creating /
Creating a new project
further enhancements /
Further enhancements
compileShaders method /
The compileShaders method
Component class
about /
The Component class
cube
about /
Hello, cube!
model data /
The cube model data
code /
Cube code
spinning /
Spinning the cube
animating /
Time for animation
cube, with face normals
about /
Cube with face normals
Cube RenderObject component
about /
The Cube RenderObject component
culling /
Introducing geometry
current shortcut
highlighting /
Highlighting the current shortcut
D
2D texture-based visualization
about /
2D texture-based visualization
texture generator /
Texture generator and loader
texture loader /
Texture generator and loader
Waveform shaders /
Waveform shaders
basic waveform Material /
Basic waveform material
Waveform visualization /
Waveform visualization
3D camera
about /
3D camera, perspective, and head rotation
3D models
extents /
Model extents, scaling, and center
scaling /
Model extents, scaling, and center
center /
Model extents, scaling, and center
teapot model, viewing /
I'm a little teapot
rotating teapot model, viewing /
I'm a little rotating teapot
3D model viewer project
setting up /
Setting up a new project
threading, adding /
Thread safe
intent, launching with /
Launch with intent
practical and production ready /
Practical and production ready
360-degree photo
viewing /
Viewing a 360-degree photo
sample photosphere, viewing /
Viewing a sample photosphere
background image, using /
Using the background image
Dalvik virtual machine (DVM) /
A Gradle build process
day and night material
about /
Day and night material
day/night shader /
Day/night shader
DayNightMaterial class /
The DayNightMaterial class
rendering with /
Rendering with day/night
depth masking /
Further possible enhancements
draw method /
VertexColorMaterial
E
Earth
fine tuning /
Fine tuning the Earth
Earth texture material
adding /
Adding the Earth texture material
texture file, loading /
Loading a texture file
diffuse lighting shaders /
Diffuse lighting shaders
diffuse lighting material /
Diffuse lighting material
diffuse lighting texture, adding to Sphere component /
Adding diffuse lighting texture to a Sphere component
viewing /
Viewing the Earth
camera position, changing /
Changing the camera position
Embedded Systems /
Introducing OpenGL ES 2.0
enhancements, music visualizer project
animations /
Further enhancements
advanced textures and shaders /
Further enhancements
texture mapping /
Further enhancements
render to texture /
Further enhancements
parametric geometry /
Further enhancements
community invite /
A community invite
entity component pattern
URL /
Introducing RenderBox – a graphics engine
equirectangular projection
reference /
Viewing a 360-degree photo
F
FFT visualization
about /
FFT visualization
,
FFT visualization
FFT audio data, capturing /
Capture the FFT audio data
FFT shaders /
FFT shaders
basic FFT Material /
Basic FFT material
field of view (FOV)
about /
Cardware!
fine tuning, Earth
about /
Fine tuning the Earth
night texture /
The night texture
axis tilt and wobble /
Axis tilt and wobble
floor
about /
Hello, floor!
shaders /
Shaders
model data /
Floor model data
variables /
Variables
onCreate /
onCreate
onSurfaceCreated /
onSurfaceCreated
initializeScene /
initializeScene
prepareRenderingFloor /
prepareRenderingFloor
onDrawEye /
onDrawEye
drawFloor /
drawFloor
Frequency
about /
Capturing audio data
front-facing /
Introducing geometry
G
Gallery360 project
setting up /
Setting up the new project
launching, with intent /
Launch with an intent
RenderBox library, updating /
Updating the RenderBox library
enhancements /
Further possible enhancements
gateway to VR
about /
A gateway to VR
gaze, loading
about /
Gaze to load
gaze-based highlights /
Gaze-based highlights
photos, selecting /
Selecting and showing photos
photos, displaying /
Selecting and showing photos
events, queuing /
Queue events
vibrator, using /
Using a vibrator
Gekkopod
URL /
Building and running
geometry
about /
Introducing geometry
Goldberg polyhedra
reference /
Further enhancements
Google Cardboard SDK guide
URL /
Going native
Google Developers Cardboard Getting Started page
URL /
Adding the Cardboard Java SDK
Google Expeditions
reference /
The value of low-end VR
Gradle build process
about /
A Gradle build process
URL /
A Gradle build process
graphics processor (GPU) /
Introducing RenderBox – a graphics engine
grid
showing/hiding, with tilt-up gestures /
Showing/hiding the grid with tilt-up gestures
H
head-mounted displays (HMD) /
Desktop VR and beyond
head look
responding to /
Responding to head look
head rotation
about /
3D camera, perspective, and head rotation
heads-up display (HUD)
about /
Adding Hello Virtual World text overlay
Hello Virtual World text overlay
adding /
Adding Hello Virtual World text overlay
simple text overlay /
A simple text overlay
text, centering with child view /
Center the text using a child view
stereoscopic views, creating for each eye /
Create stereoscopic views for each eye
overlay view, controlling from MainActivity /
Controlling the overlay view from MainActivity
I
icon
adding, to view /
Adding an icon to the view
IDE (integrated development environment) /
Getting started with Android Studio
Image.loadLock /
Stay responsive and use threads
image gallery user interface
about /
The image gallery user interface
features /
The image gallery user interface
photo screen, positioning on left /
Positioning the photo screen on the left
IntelliJ IDEA
URL /
The Android Studio user interface
intent
about /
Launch with an intent
,
Launch with intent
intent metadata /
The AndroidManifest.xml file
isLookingAtObject method
about /
The isLookingAtObject method
J
Java compiler
about /
A Java compiler
Java Virtual Machine (JVM) /
The Math package
L
Light
about /
Introducing RenderBox – a graphics engine
Light component
about /
The Light component
low-end VR
about /
The value of low-end VR
M
MainActivity.cancelUpdate /
Stay responsive and use threads
MainActivity class
about /
The MainActivity class
Default onCreate /
Default onCreate
building /
Building and running
running /
Building and running
MainActivity gridUpdateLock /
Stay responsive and use threads
map projections and spherical distortions
reference /
Viewing a 360-degree photo
materials
about /
Materials, textures, and shaders
textured material /
Materials, textures, and shaders
shaders /
Materials, textures, and shaders
abstract material /
Abstract material
Math package
about /
The Math package
MathUtils /
MathUtils
Matrix4 /
Matrix4
quaternion /
Quaternion
Vector2 /
Vector2
Vector3 /
Vector3
MathUtils variables
about /
MathUtils
matrix
about /
Welcome to the matrix
URL /
Welcome to the matrix
Matrix4 class
about /
Matrix4
MilkDrop
reference /
Further enhancements
model-view-perspective (MVP) transformation matrices /
VertexColorMaterial
ModelObject class
creating /
Creating the ModelObject class
modules /
Exporting the RenderBox package
multiple simultaneous visualizations
about /
Multiple simultaneous visualizations
music visualizer project
setting up /
Setting up a new project
enhancements /
Further enhancements
MVP vertex shader
about /
The MVP vertex shader
N
normal vector /
Cube normals and colors
numeric literals /
Adding shaders
O
objects
detecting /
Detect looking at objects
OBJ file format
about /
Understanding the OBJ file format
reference /
Understanding the OBJ file format
OBJ models
parsing /
Parse OBJ models
buildBuffers /
buildBuffers
onDrawEye /
onDrawEye
OpenGL ES 2.0
about /
Introducing OpenGL ES 2.0
OpenGL ES graphics processing services
running /
The AndroidManifest.xml file
OpenGL rendering pipeline
URL /
Introducing OpenGL ES 2.0
P
parent methods
setParent /
Parent methods
unParent /
Parent methods
about /
Parent methods
perspective
about /
3D camera, perspective, and head rotation
viewing matrices, setting up /
Setting up the perspective viewing matrices
render /
Render in perspective
app, building /
Building and running
app, running /
Building and running
photo image
loading /
Loading and displaying a photo image
displaying /
Loading and displaying a photo image
image class, defining /
Defining the image class
images, reading into app /
Reading images into the app
image load texture /
Image load texture
image, displaying on screen /
Showing an image on the screen
correct orientation, rotating to /
Rotating to the correct orientation
dimensions, for correcting width and height /
Dimensions to correct the width and height
sample image down to size /
Sample image down to size
photosphere image
loading /
Loading and displaying a photosphere image
displaying /
Loading and displaying a photosphere image
Photosphere mode /
Loading and displaying a photosphere image
Planet class
creating /
Creating a Planet class
position methods
setPosition /
Position methods
getPosition /
Position methods
postDraw
about /
A VisualizerBox architecture
preDraw
about /
A VisualizerBox architecture
prepareRenderingTriangle method /
The prepareRenderingTriangle method
profile generator tools
reference /
Configuring your Cardboard viewer
project
creating /
Creating a new project
Q
quaternion
about /
Quaternion
references /
Quaternion
R
random visualizations
about /
Random visualizations
regular photo
viewing /
Viewing a regular photo
Plane component, defining /
Defining the Plane component and allocating buffers
allocating buffers, defining /
Defining the Plane component and allocating buffers
materials, adding to Plane component /
Adding materials to the Plane component
image screen, adding to scene /
Adding an image screen to the scene
RenderBox
about /
Introducing RenderBox – a graphics engine
new project, creating /
Creating a new project
package folder, creating /
Creating the RenderBox package folder
empty RenderBox class, creating /
Creating an empty RenderBox class
IRenderBox interface, adding /
Adding the IRenderBox interface
RenderBox library
updating /
Updating the RenderBox library
RenderBox methods
about /
RenderBox methods
RenderBox package
exporting /
Exporting the RenderBox package
RenderBoxLib module, building /
Building the RenderBoxLib module
RenderBox test app /
The RenderBox test app
RenderBox, using in future projects /
Using RenderBox in future projects
RenderObject
about /
Introducing RenderBox – a graphics engine
RenderObject component
about /
The RenderObject component
rotation methods
setRotation /
Rotation methods
S
Sacred geometry
reference /
Further enhancements
sampler function /
Diffuse lighting shaders
scale methods
setScale /
Scale methods
scrolling, enabling
about /
Enable scrolling
Triangle component, creating /
Creating the Triangle component
triangles, adding to UI /
Adding triangles to the UI
scroll buttons, interacting with /
Interacting with the scroll buttons
scrolling method, implementing /
Implementing the scrolling method
setBuffers method /
VertexColorMaterial
setup
about /
A VisualizerBox architecture
setupProgram method /
VertexColorMaterial
shaders
about /
Lighting and shading
adding /
Adding shaders
cube normals and colors /
Cube normals and colors
vertex buffers, preparing /
Preparing the vertex buffers
preparing /
Preparing the shaders
light source, adding /
Adding a light source
app, building /
Building and running the app
app, running /
Building and running the app
shading /
Cube code
simple box scene
about /
A simple box scene
smooth shading /
Cube normals and colors
software development kit (SDK)
about /
Why is it called Cardboard?
Solar System project
creating /
Setting up a new project
formation /
Formation of the Solar System
planets, setting up in MainActivity /
Setting up planets in MainActivity
camera's planet view /
Camera's planet view
heavenly bodies, animating /
Animating the heavenly bodies
enhancements /
Possible enhancements
solid color lighted sphere
about /
A solid color lighted sphere
solid color lighting shaders /
Solid color lighting shaders
solid color lighting material /
Solid color lighting material
Material, adding to Sphere /
Adding a Material to a Sphere
Sphere, viewing /
Viewing the Sphere
spectrum, VR devices
old fashioned stereoscopes /
Old fashioned stereoscopes
Cardboard, as mobile VR /
Cardboard is mobile VR
desktop VR /
Desktop VR and beyond
Sphere component
creating /
Creating a Sphere component
spherical thumbnails
about /
Spherical thumbnails
sphere, adding to Thumbnail class /
Add a sphere to the Thumbnail class
starry sky dome
about /
A starry sky dome
Sun
creating /
Creating the Sun
unlit texture shaders /
Unlit texture shaders
unlit texture material /
Unlit texture material
unlit texture, rendering with /
Rendering with an unlit texture
adding /
Adding the Sun
Surround Shot /
Loading and displaying a photosphere image
T
threading
about /
An explanation of threading and virtual reality
threads
using /
Stay responsive and use threads
Thumbnail class
about /
The Thumbnail class
thumbnail grid
about /
The thumbnail grid
thumbnail image
about /
The thumbnail image
thumbnails
displaying, in grid /
Displaying thumbnails in a grid
tilt-up gestures
for showing/hiding grid /
Showing/hiding the grid with tilt-up gestures
tilt damper feature /
Showing/hiding the grid with tilt-up gestures
Tissot's Indicatrix
reference /
Viewing a 360-degree photo
Titans of Space
URL /
Setting up planets in MainActivity
Transform class
about /
The Transform class
parent methods /
Parent methods
position methods /
Position methods
rotation methods /
Rotation methods
scale methods /
Scale methods
identity matrix, transforming /
Transform to matrix and draw
drawMatrix() function /
Transform to matrix and draw
drawMatrices method /
Transform to matrix and draw
translation, rotation, and scale (TRS) /
The Transform class
Treasure Hunt /
The Android Studio user interface
tri-angle!
about /
Introducing geometry
triangle
about /
Hello, triangle!
geometry /
Introducing geometry
variables /
Triangle variables
onSurfaceCreated /
onSurfaceCreated
OpenGL ES 2.0 /
Introducing OpenGL ES 2.0
simple shaders /
Simple shaders
compileShaders method /
The compileShaders method
prepareRenderingTriangle method /
The prepareRenderingTriangle method
onDrawEye /
onDrawEye
app, building /
Building and running
app, running /
Building and running
repositioning /
Repositioning the triangle
trigger
used, for picking and launching app /
Using the trigger to pick and launch the app
trippy trails mode
about /
Trippy trails mode
U
Unity
reference /
Using Unity
about /
Using Unity
using /
Using Unity
Unity 3D game engine
URL /
Why is it called Cardboard?
V
VBO (Vertex Buffer Object) /
Introducing OpenGL ES 2.0
Vector2
about /
Vector2
Vector3
about /
Vector3
vertex color lighting material
about /
Vertex color lighting material and shaders
vertex color lighting shaders
about /
Vertex color lighting material and shaders
VertexColorMaterial class
about /
VertexColorMaterial
VertexColorMaterial instance
defining /
Vertex color material and shaders
VertexColorMaterial method /
VertexColorMaterial
vertex color shaders
about /
Vertex color shaders
ViewMaster brand VR/AR viewer
URL /
Old fashioned stereoscopes
virtual screen
using /
Using a virtual screen
VisualizerBox architecture
about /
A VisualizerBox architecture
VR best practices
overview /
An overview to VR best practices
VR devices
spectrum /
The spectrum of VR devices
W
Waveform
about /
Capturing audio data
Waveform data capture
about /
Waveform data capture
Wearality viewer
URL /
Cardware!
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset