Hey, look at this!

In the last part of the project, we add a feature that detects when you're looking at an object (the cube) and highlights it with a different color.

This is accomplished with the help of the CardboardView interface method, onNewFrame, which passes the current head transformation information.

The isLookingAtObject method

Let's start with the most interesting part. We'll borrow the isLookingAtObject method from Google's Treasure Hunt demo. It checks whether the user is looking at an object by calculating where the object is in the eye space and returns true if the user is looking at the object. Add the following code to MainActivity:

/** * Check if user is looking at object by calculating where the object is in eye-space. * * @return ...

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.