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 RenderObject component

RenderObject will serve as the parent class of geometric objects that can be rendered in the scene. RenderObject extends Component, so it has a Transform.

In the renderbox/components folder, create a new Java class, RenderObject. Define it as an abstract class that extends Component:

public abstract class RenderObject extends Component {
    private static final String TAG = "RenderObject";

    public RenderObject(){
        super();
        RenderBox.instance.renderObjects.add(this);
    }
}

The first thing we do is have each instance add itself to the list of renderObjects maintained by the RenderBox instance. Let's jump over to the RenderBox class now and add support for this list.

Open the RenderBox.java file and add a renderObjects list:

public ...

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