Using a virtual screen
In virtual reality, the space you are looking into is bigger than what is on the screen at a given time. The screen is like a viewport into the virtual space. In this project, we're not calculating 3D views and clipping planes, and we're constraining the head motion to left/right yaw rotation.
You can think of the visible space as the inside surface of a cylinder, with your head at the center. As you rotate your head, a portion of the unraveled cylinder is displayed on the screen.
The height of the virtual screen in pixels is the same as the physical device.
We need to calculate the virtual width. One way to do this, for example, would be to figure out the number of pixels in one degree of head rotation. Then, the width of a full rotation would be pixels per degree * 360.
We can easily find the physical width of the display in pixels. In fact, we already found it in onLayout
as the viewWidth
variable. Alternatively, it can be retrieved from the Cardboard SDK call:
ScreenParams...