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

Model extents, scaling, and center

3D models come in all shapes and sizes. To view them in our app, we need to know the minimum and maximum boundaries of the model and its geometric center to scale and position it properly. Let's add this to ModelObject now.

At the top of the ModelObject class, add the following variables:

    public Vector3 extentsMin, extentsMax;

Initialize the extents in the parser, before we parse the model data. The minimum extents are initialized to the maximum possible values; the maximum extents are initialized to the minimum possible values:

 public ModelObject(int objFile) { super(); extentsMin = new Vector3(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE); extentsMax = new Vector3(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE); ...

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