Creating the ModelObject class

To begin with, we will define a ModelObject class that extends RenderObject. It will load model data from OBJ files and set up buffers needed by its material (and OpenGL ES shaders to be rendered in the VR scene).

Right-click on the app/java/com.cardboardvr.modelviewer/ folder, go to New | Java Class, and name it ModelObject. Define it so that it extends RenderObject, as follows:

public class ModelObject extends RenderObject {
}

Just like we've done in the previous chapters, when introducing new kinds of RenderObjects, we'll have one or more constructors that can instantiate a Material and set up buffers. For ModelObject, we'll pass in a file resource handle, parse the file (refer to the next topic), and create a solid ...

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.