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 color material (initially, without lighting), as follows:
public ModelObject(int objFile) { super(); InputStream inputStream = RenderBox.instance.mainActivity.getResources().openRawResource(objFile); if...