The Component class

Our 3D virtual reality scenes consist of various kinds of components. Components may include geometric objects, lights, and cameras. Components can be positioned, rotated, and scaled in 3D space, according to their associated transform. Let's create a Component class that will serve as the basis for other object classes in the scene.

If you haven't created Component.java yet, create one now in the renderbox/components folder. Define it as follows:

public class Component {
    public Transform transform;

    public boolean enabled = true;
}

We've included an enabled flag, which will come in handy to easily hide/show objects when we draw our scene.

That's it. Next, we'll define our first component, RenderObject, to represent geometric objects ...

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.