SlideShare a Scribd company logo
1 of 13
Coding a VR
Application
in Android
A Practical Guide
Virtual Reality @
CommonFloor
Virtual Reality @
CommonFloor
Contents
❖ Introduction to Google Cardboard SDK for Android
❖ Requirement of separate SDK for VR ?
❖ Getting Started with First Android Application for VR
❖ Setup of coding environment
❖ Overview of code
Intro to Google Cardboard
SDK
❖ Cardboard SDK for Android enables developers familiar with OpenGL to
quickly start creating VR applications.
❖ The toolkit simplifies many common VR development tasks, including:
❖ Lens distortion correction.
❖ Head tracking.
❖ 3D calibration.
❖ Side-by-side rendering.
❖ Stereo geometry configuration.
❖ User input event handling.
Setup of Coding Environment
❖ Building the demo app requires:
❖ Android Studio 1.0 or higher
❖ https://developer.android.com/sdk/index.html
❖ Version 19 of the Android SDK
❖ A physical Android device running Android 16 (Jelly
Bean) or higher
Lets start coding
❖ Main components of Android VR Application
❖ Manifest file
❖ Cardboard Activity
❖ Custom Renderer
❖ Content Model
Android Manifest File
Need to specify following permissions in manifest file
❖ NFC — Input Mechanism used by cardboard trigger button
<uses-permission android:name="android.permission.NFC" />
❖ Vibration Sensor — Haptic Feedback mechanism for certain events in Application
<uses-permission android:name="android.permission.VIBRATE" />
❖ Read and write to external storage
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
❖ Specify minimum and target SDK version
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19"/>
❖ Specify the OpenGL ES version that device must support to run the application
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Cardboard Activity
❖ Starting point for coding a cardboard app.
❖ Base activity that provides easy integration with
Cardboard devices.
❖ Exposes events to interact with Cardboards.
❖ Uses sticky immersive mode, in which the system UI is
hidden, and the content takes up the whole screen.
Custom Renderer
❖ Custom Renderer for CardboardView
❖ Implements the CardboardView.StereoRenderer interface
❖ Delegates all stereoscopic rendering details to the view
❖ All stereoscopic rendering and distortion correction details are abstracted from the renderer and managed
internally by the view
❖ Overrides the following important methods
// Prepares OpenGL ES before we draw a frame.
// @param headTransform The head transformation in the new frame.
@Override
public void onNewFrame(HeadTransform headTransform) {
// Called when a new frame is about to be drawn.
// Any per-frame operations not specific to a single view should happen here.
}
@Override
public void onDrawEye(Eye eye) {
// Draw the frames for each eye
}
Custom Renderer
OnDrawEye Function
// Draws a frame for an eye.
// @param eye The eye to render. Includes all required transformations.
@Override
public void onDrawEye(Eye eye) {
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
. . .
// Apply the eye transformation to the camera.
Matrix.multiplyMM(mView, 0, eye.getEyeView(), 0, mCamera, 0);
// Set the position of the light
Matrix.multiplyMV(mLightPosInEyeSpace, 0, mView, 0, LIGHT_POS_IN_WORLD_SPACE, 0);
// Build the ModelView and ModelViewProjection matrices
// for calculating cube position and light.
float[] perspective = eye.getPerspective(Z_NEAR, Z_FAR);
Matrix.multiplyMM(mModelView, 0, mView, 0, mModelCube, 0);
Matrix.multiplyMM(mModelViewProjection, 0, perspective, 0, mModelView, 0);
drawCube();
// Draw rest of the scene.
. . .
}
Content for VR - 3D Models
❖ Consists of any 3D model that we want to render in our application
❖ Can be a simple model like a sphere or cube
❖ Can be complex models of house, players etc to create a real 3D
scene.
Wrap it up and Lets Code !!!
3D
Assets
Carboard.jar
Google Cardboard
Android Application
Redistributable
APK
Cardboard SDK
Compatible
Android Phone
+ =
=
Android
Code +

More Related Content

What's hot

What's hot (18)

Augmented Reality Application Tutorial for Education 2
Augmented  Reality Application Tutorial for Education 2Augmented  Reality Application Tutorial for Education 2
Augmented Reality Application Tutorial for Education 2
 
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
Giovanni Laquidara - Hello ARCore - Codemotion Milan 2017
 
Mobile AR Lecture 5 - Location Based AR
Mobile AR Lecture 5 - Location Based ARMobile AR Lecture 5 - Location Based AR
Mobile AR Lecture 5 - Location Based AR
 
Augmented Reality Application Tutorial for Education 1
Augmented  Reality Application Tutorial for Education 1Augmented  Reality Application Tutorial for Education 1
Augmented Reality Application Tutorial for Education 1
 
Unity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All SlidesUnity - Building Your First Real-Time 3D Project - All Slides
Unity - Building Your First Real-Time 3D Project - All Slides
 
SAE AR/VR - The challenges of creating a VR application with Unity
SAE AR/VR - The challenges of creating a VR application with UnitySAE AR/VR - The challenges of creating a VR application with Unity
SAE AR/VR - The challenges of creating a VR application with Unity
 
Make believe - Droidcon UK 2015
Make believe - Droidcon UK 2015Make believe - Droidcon UK 2015
Make believe - Droidcon UK 2015
 
【Unite 2017 Tokyo】「日本列島VR」および「HoleLenz」の開発事例ご紹介
【Unite 2017 Tokyo】「日本列島VR」および「HoleLenz」の開発事例ご紹介【Unite 2017 Tokyo】「日本列島VR」および「HoleLenz」の開発事例ご紹介
【Unite 2017 Tokyo】「日本列島VR」および「HoleLenz」の開発事例ご紹介
 
Mixed reality for Windows 10
Mixed reality for Windows 10Mixed reality for Windows 10
Mixed reality for Windows 10
 
AR Foundation framework: product roadmap – Unite Copenhagen 2019
AR Foundation framework: product roadmap – Unite Copenhagen 2019AR Foundation framework: product roadmap – Unite Copenhagen 2019
AR Foundation framework: product roadmap – Unite Copenhagen 2019
 
Extended Reality in Game Design
Extended Reality in Game DesignExtended Reality in Game Design
Extended Reality in Game Design
 
Game Development in VR
Game Development in VR Game Development in VR
Game Development in VR
 
Cardboard VR: Building Low Cost VR Experiences
Cardboard VR: Building Low Cost VR ExperiencesCardboard VR: Building Low Cost VR Experiences
Cardboard VR: Building Low Cost VR Experiences
 
Improving the VR experience - VRST 2012
Improving the VR experience - VRST 2012Improving the VR experience - VRST 2012
Improving the VR experience - VRST 2012
 
Unity - Essentials of Programming in Unity
Unity - Essentials of Programming in UnityUnity - Essentials of Programming in Unity
Unity - Essentials of Programming in Unity
 
Synthetic environment
Synthetic environmentSynthetic environment
Synthetic environment
 
Google daydream
Google daydreamGoogle daydream
Google daydream
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with Unity
 

Viewers also liked

Virtual reality
Virtual realityVirtual reality
Virtual reality
Shruti Singh
 
Virtual reality Presentation
Virtual reality PresentationVirtual reality Presentation
Virtual reality Presentation
Anand Akshay
 
Final presentation of virtual reality by monil
Final presentation of virtual reality by monilFinal presentation of virtual reality by monil
Final presentation of virtual reality by monil
ritik456
 

Viewers also liked (16)

A virtual reality applications gallery
A virtual reality applications galleryA virtual reality applications gallery
A virtual reality applications gallery
 
Education and Virtual Reality - Reimagining education with VR
Education and Virtual Reality - Reimagining education with VREducation and Virtual Reality - Reimagining education with VR
Education and Virtual Reality - Reimagining education with VR
 
Virtual reality
Virtual realityVirtual reality
Virtual reality
 
User involvement in design and application of virtual reality gamification to...
User involvement in design and application of virtual reality gamification to...User involvement in design and application of virtual reality gamification to...
User involvement in design and application of virtual reality gamification to...
 
VR & Education: Collaboration-vs-Simulation
VR & Education: Collaboration-vs-SimulationVR & Education: Collaboration-vs-Simulation
VR & Education: Collaboration-vs-Simulation
 
Virtual Reality In Architecture
Virtual Reality In ArchitectureVirtual Reality In Architecture
Virtual Reality In Architecture
 
NCIT 2015 - Virtual Reality Application to simulation and control walking pla...
NCIT 2015 - Virtual Reality Application to simulation and control walking pla...NCIT 2015 - Virtual Reality Application to simulation and control walking pla...
NCIT 2015 - Virtual Reality Application to simulation and control walking pla...
 
Virtual reality
Virtual realityVirtual reality
Virtual reality
 
Virtual reality Presentation
Virtual reality PresentationVirtual reality Presentation
Virtual reality Presentation
 
VR in Education: How Virtual Reality Can Impact Learning
VR in Education: How Virtual Reality Can Impact LearningVR in Education: How Virtual Reality Can Impact Learning
VR in Education: How Virtual Reality Can Impact Learning
 
Virtual Reality
Virtual RealityVirtual Reality
Virtual Reality
 
Final presentation of virtual reality by monil
Final presentation of virtual reality by monilFinal presentation of virtual reality by monil
Final presentation of virtual reality by monil
 
The Emerging Virtual Reality Landscape: a Primer
The Emerging Virtual Reality Landscape: a PrimerThe Emerging Virtual Reality Landscape: a Primer
The Emerging Virtual Reality Landscape: a Primer
 
Virtual Reality
Virtual RealityVirtual Reality
Virtual Reality
 
Virtual Reality
Virtual RealityVirtual Reality
Virtual Reality
 
Virtual Reality-Seminar presentation
Virtual Reality-Seminar  presentationVirtual Reality-Seminar  presentation
Virtual Reality-Seminar presentation
 

Similar to Developing Virtual Reality Application using Google Cardboard

Springboard & OpenCV
Springboard & OpenCVSpringboard & OpenCV
Springboard & OpenCV
Cruise Chen
 

Similar to Developing Virtual Reality Application using Google Cardboard (20)

Virtual Reality in Android
Virtual Reality in AndroidVirtual Reality in Android
Virtual Reality in Android
 
Google VR SDK 101
Google VR SDK 101Google VR SDK 101
Google VR SDK 101
 
Spooky House Studios: Game development for smartwatches. Challenges and solut...
Spooky House Studios: Game development for smartwatches. Challenges and solut...Spooky House Studios: Game development for smartwatches. Challenges and solut...
Spooky House Studios: Game development for smartwatches. Challenges and solut...
 
Dissecting and fixing Vulkan rendering issues in drivers with RenderDoc
Dissecting and fixing Vulkan rendering issues in drivers with RenderDocDissecting and fixing Vulkan rendering issues in drivers with RenderDoc
Dissecting and fixing Vulkan rendering issues in drivers with RenderDoc
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 
[1C7] Developing with Oculus
[1C7] Developing with Oculus[1C7] Developing with Oculus
[1C7] Developing with Oculus
 
Visage fx
Visage fxVisage fx
Visage fx
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScript
 
How to Use OpenGL/ES on Native Activity
How to Use OpenGL/ES on Native ActivityHow to Use OpenGL/ES on Native Activity
How to Use OpenGL/ES on Native Activity
 
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
 
3D Programming Basics: WebGL
3D Programming Basics: WebGL3D Programming Basics: WebGL
3D Programming Basics: WebGL
 
Net core
Net coreNet core
Net core
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009
 
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
Android Things, from mobile apps to physical world - Stefano Sanna - Giovanni...
 
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
Android Things, from mobile apps to physical world by Giovanni Di Gialluca an...
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by step
 
Android Things, from mobile apps to physical world
Android Things, from mobile apps to physical worldAndroid Things, from mobile apps to physical world
Android Things, from mobile apps to physical world
 
Springboard & OpenCV
Springboard & OpenCVSpringboard & OpenCV
Springboard & OpenCV
 
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008"JavaME + Android in action" CCT-CEJUG Dezembro 2008
"JavaME + Android in action" CCT-CEJUG Dezembro 2008
 
Introduction to Android - Mobile Portland
Introduction to Android - Mobile PortlandIntroduction to Android - Mobile Portland
Introduction to Android - Mobile Portland
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Developing Virtual Reality Application using Google Cardboard

  • 1. Coding a VR Application in Android A Practical Guide
  • 4. Contents ❖ Introduction to Google Cardboard SDK for Android ❖ Requirement of separate SDK for VR ? ❖ Getting Started with First Android Application for VR ❖ Setup of coding environment ❖ Overview of code
  • 5. Intro to Google Cardboard SDK ❖ Cardboard SDK for Android enables developers familiar with OpenGL to quickly start creating VR applications. ❖ The toolkit simplifies many common VR development tasks, including: ❖ Lens distortion correction. ❖ Head tracking. ❖ 3D calibration. ❖ Side-by-side rendering. ❖ Stereo geometry configuration. ❖ User input event handling.
  • 6. Setup of Coding Environment ❖ Building the demo app requires: ❖ Android Studio 1.0 or higher ❖ https://developer.android.com/sdk/index.html ❖ Version 19 of the Android SDK ❖ A physical Android device running Android 16 (Jelly Bean) or higher
  • 7. Lets start coding ❖ Main components of Android VR Application ❖ Manifest file ❖ Cardboard Activity ❖ Custom Renderer ❖ Content Model
  • 8. Android Manifest File Need to specify following permissions in manifest file ❖ NFC — Input Mechanism used by cardboard trigger button <uses-permission android:name="android.permission.NFC" /> ❖ Vibration Sensor — Haptic Feedback mechanism for certain events in Application <uses-permission android:name="android.permission.VIBRATE" /> ❖ Read and write to external storage <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> ❖ Specify minimum and target SDK version <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19"/> ❖ Specify the OpenGL ES version that device must support to run the application <uses-feature android:glEsVersion="0x00020000" android:required="true" />
  • 9. Cardboard Activity ❖ Starting point for coding a cardboard app. ❖ Base activity that provides easy integration with Cardboard devices. ❖ Exposes events to interact with Cardboards. ❖ Uses sticky immersive mode, in which the system UI is hidden, and the content takes up the whole screen.
  • 10. Custom Renderer ❖ Custom Renderer for CardboardView ❖ Implements the CardboardView.StereoRenderer interface ❖ Delegates all stereoscopic rendering details to the view ❖ All stereoscopic rendering and distortion correction details are abstracted from the renderer and managed internally by the view ❖ Overrides the following important methods // Prepares OpenGL ES before we draw a frame. // @param headTransform The head transformation in the new frame. @Override public void onNewFrame(HeadTransform headTransform) { // Called when a new frame is about to be drawn. // Any per-frame operations not specific to a single view should happen here. } @Override public void onDrawEye(Eye eye) { // Draw the frames for each eye }
  • 11. Custom Renderer OnDrawEye Function // Draws a frame for an eye. // @param eye The eye to render. Includes all required transformations. @Override public void onDrawEye(Eye eye) { GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); . . . // Apply the eye transformation to the camera. Matrix.multiplyMM(mView, 0, eye.getEyeView(), 0, mCamera, 0); // Set the position of the light Matrix.multiplyMV(mLightPosInEyeSpace, 0, mView, 0, LIGHT_POS_IN_WORLD_SPACE, 0); // Build the ModelView and ModelViewProjection matrices // for calculating cube position and light. float[] perspective = eye.getPerspective(Z_NEAR, Z_FAR); Matrix.multiplyMM(mModelView, 0, mView, 0, mModelCube, 0); Matrix.multiplyMM(mModelViewProjection, 0, perspective, 0, mModelView, 0); drawCube(); // Draw rest of the scene. . . . }
  • 12. Content for VR - 3D Models ❖ Consists of any 3D model that we want to render in our application ❖ Can be a simple model like a sphere or cube ❖ Can be complex models of house, players etc to create a real 3D scene.
  • 13. Wrap it up and Lets Code !!! 3D Assets Carboard.jar Google Cardboard Android Application Redistributable APK Cardboard SDK Compatible Android Phone + = = Android Code +