The Cube RenderObject component

For demonstration purposes, we'll start with a simple cube. Later on, we'll improve it with lighting. In Chapter 3, Cardboard Box, we defined a Cube model. We'll start by using the same class and data structure here. You can even copy the code, but it's shown in the following text. Create a Cube Java class in the renderbox/components/ folder:

// File: renderbox/components/Cube.java public class Cube { public static final float[] CUBE_COORDS = new float[] { // Front face -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, // Right face 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, // Back ...

Get Cardboard VR Projects for Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.