Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Virtual Reality in Android

This is my talk I held at www.droidcon.ro in 2016. I talked about what a cardboard is, how to use it, how to program it and I ran through the description of the demo app. Based on this demo, I explored on how to separate parts of it to create a Virtual Reality App, capable of using our Content Modelling System(Contentful) to change what the user will see ...

  • Identifiez-vous pour voir les commentaires

Virtual Reality in Android

  1. 1. Mario Bodemann Android and Java Evangelist @mariobodemann @contentful Virtual Reality in Android
  2. 2. API driven CMS, emphasis on content creation and delivery.
  3. 3. Virtual Reality in Android Using Cardboard
  4. 4. What is Cardboard? ● Easy to produce ● Available from different companies and in different shapes ● can have a button/lever/hole for interaction ● only needs a smart phone (Android/ios) and an App
  5. 5. How does it work? ● Use 3D data and movement to draw two images: left and right eye ● Distort images for lenses ● Combine image to scene in brain
  6. 6. Programming Cardboard
  7. 7. How do I program Cardboard? https://developers.google.com/cardboard/android/ ● SDKs available for ● Java ○ OpenGL ○ Pure Android ● Unity Plugin ○ Unity Engine (C# /JS) ○ Platform independent ○ No reliable linux development available
  8. 8. ● Demo app ○ Find a box and press the button ○ On github ● Library ○ jar distributed with demo repository ○ no maven repository How To: Android Demo https://github.com/googlesamples/cardboard-java
  9. 9. Setup of the demo Activity Model Repository OpenGL Interaction ● All code in one Activity ○ OpenGL code ○ Model creation ● Hard to expand on
  10. 10. Expanding on the demo
  11. 11. ● App using above code as base ● Expanding it to new use cases ● Having fun exploring Contentful Cardboard Idea https://github.com/contentful-labs/contentful-cardboard https://play.google.com/apps/testing/com.contentful.cardboard
  12. 12. MVPR Presenter Model Repository OpenGL Interaction Interactor Activity (View) VR Renderer ● Split Activity into several parts ● Improve modularity ● Improve testability ● Improve readability ● Improve line number count ;)
  13. 13. Interactor ● Repository abstraction ● Uses registered Listener to inform Presenter ● Live time of the Presenter public interface Interactor { interface Listener { void onModelReceived(ProtoModel model); void onError(Throwable throwable); } void setListener(Listener listener); void requestModels(); }
  14. 14. Presenter ● Coordinates Interactor and View ● Enriches data from Interactor ● Tells View to update its models public class Presenter implements Interactor.Listener { // … setup private int received = 0; @Override public void onModelReceived (ProtoModel model) { model.position[0] += received * 4.0f; received++; view.addProtoModel(model); }
  15. 15. View ● Connects Renderer and Presenter ● Takes models and enqueues them in the renderer ● Startup point for Android app ● Deals with interaction public class MainActivity extends CardboardActivity implements CardboardView.StereoRenderer, View { @Override public void onCreate(…) { renderer = new CardboardRenderer( getApplicationContext()); presenter = new Presenter( new ContentfulInteractor(this)); presenter.bind(this); } @Override public void onCardboardTrigger() { vibrator.vibrate(25); userInteracted();
  16. 16. View (cont.) ● Listens to Cardboard Library callbacks ● For setup of a frame ● And rendering every eye, redirecting it to the renderer @Override public void onSurfaceCreated(…) { renderer.surfaceCreated(); } @Override public void onNewFrame( HeadTransform headTransform) { renderer.prepare(); } @Override public void onDrawEye(Eye eye) { float[] perspective = eye.getPerspective (Z_NEAR, Z_FAR); float[] eyeView = eye.getEyeView(); renderer.render(perspective, eyeView); }
  17. 17. Renderer public class CardboardRenderer implements Renderer { @Override public void surfaceCreated() { addFloorAndCeiling(); } @Override public void prepare() { addPendingModels(); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); // … More gl* calls } ● Abstracts from OpenGL rendering ● Generates OpenGL GPU Models ● Listens to View
  18. 18. @Override public void render(float[] perspective, float[] eyeView) { multiplyMM(view, 0, eyeView, 0, camera, 0); for (final Model model : backgroundModels) { renderModel(perspective, model); } for (final Model model : foregroundModels) { renderModel(perspective, model); } } Renderer (cont.) ● Render all models added ● Starting with background objects, since foreground objects contain transparency
  19. 19. Advantage of new system
  20. 20. Sample Challenge: How to change a texture? ● Change file ● Rerun tooling ● Re releasing new version in store ● Convince user to update ● Need technical person ● Potentially through several iterations
  21. 21. Purposal: Using A CMS ● Change a asset online ● Restart app to resync data (done at startup?) ● User only needs network ● Can be done by non technical person
  22. 22. Using A CMS ● Everything except for the grid comes from CMS ● Changing it with drag and drop ● Changing VR content from outside
  23. 23. Future
  24. 24. ● Unit tests? ● Provide different Renderer VR/classic/engine code? ● CMS for Shader? ● A/B testing of in assets? ● Your ideas? Future
  25. 25. Recap
  26. 26. Recap ● Cardboard is relatively easy to program and use ● Expanding from Google Demo is the key to success ● Using a CMS for VR
  27. 27. Questions and Answers

×