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

Time for animation

It's time to throw in a little more excitement. Let's animate the cube so that it rotates. This'll help demonstrate the shading as well.

For this, we need a Time class. This is a singleton utility class that ticks off frames and makes that information available to the application, for example, via getDeltaTime. Note that this is a final class, which explicitly means that it cannot be extended. There is no such thing as a static class in Java, but if we make the constructor private, we can ensure that nothing will ever instantiate it.

Create a new Time class in the renderbox/ folder. It won't be getting extended, so we can declare it final. Here's the code:

public final class Time { private Time(){} static long startTime; static ...

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