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 face 1.0f, 1.0f, -1.0f, 1.0f, -1.0f...