O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Thread safe

In Chapter 7, 360-Degree Gallery, we explained the need for worker threads to offload processing from the render thread. In this project, we'll add threading to the ModelObject constructor where we read and parse the model files:

 public ModelObject(final int objFile) { super(); extentsMin = new Vector3(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE); extentsMax = new Vector3(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE); SolidColorLightingMaterial.setupProgram(); enabled = false; new Thread(new Runnable() { @Override public void run() { InputStream inputStream = RenderBox.instance.mainActivity.getResources().openRawResource(objFile); if (inputStream == null) return; // error createMaterial(); enabled = true; float scalar = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required