O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required