GvrViewerParams

public class GvrViewerParams

Defines the physical parameters of a Google VR viewer.

The model assumes the following for any GVR viewer:

  1. Lenses are parallel to the screen of the inserted display.
  2. The center of each lens is at the same height from the bottom of the inserted display.
  3. Lenses are symmetrically placed with respect to the center of the inserted display's screen.
  4. The size of the area visible from the center of each lens is the same.

These parameters might be different for variations of different viewers or lenses. For simplicity, they can be stored in the NFC tag of the GVR viewer.

Nested Classes

enum GvrViewerParams.VerticalAlignmentType Enum indicating the strategy for aligning the phone display vertically with respect to center of the lenses. 

Public Constructors

GvrViewerParams()
Initializes GVR viewer parameters to default values for Cardboard v2.
GvrViewerParams(GvrViewerParams params)
Creates a copy of an existing viewer params object.

Public Methods

static GvrViewerParams
cardboardV1ViewerParams()
Sets parameters to Cardboard v1.0.0
static GvrViewerParams
cardboardV2ViewerParams()
Sets parameters to Cardboard v2.2
static GvrViewerParams
createFromNfcContents(NdefMessage tagContents)
Initializes physical parameters from the contents of a GVR NFC tag.
static GvrViewerParams
createFromUri(Uri uri)
Initializes the physical parameters of a GVR headset from a Uri.
boolean
equals(Object other)
Compares this instance with the specified object and indicates if they are equal.
Distortion
getDistortion()
Returns the lens distortion model.
boolean
getHasMagnet()
Returns whether or not the GVR headset has a magnet.
float
getInterLensDistance()
Returns the inter lens distance for the viewer.
FieldOfView
getLeftEyeMaxFov()
Returns the left eye's maximum field of view visible through the lens.
String
getModel()
Returns the viewer model string.
float
getScreenToLensDistance()
Returns the screen to lens distance in meters.
String
getVendor()
Returns the viewer vendor string.
GvrViewerParams.VerticalAlignmentType
getVerticalAlignment()
Get the vertical alignment strategy.
float
getVerticalDistanceToLensCenter()
Returns the vertical distance to the lens center.
boolean
static boolean
isGvrUri(Uri uri)
Return true if given URI identifies a GVR viewer.
void
setHasMagnet(boolean magnet)
Sets whether this GVR headset has a magnet.
void
setInterLensDistance(float interLensDistance)
Sets the inter lens distance of the viewer.
void
setModel(String model)
Sets the viewer model string.
void
setScreenToLensDistance(float screenToLensDistance)
Sets the distance from the screen to the optical center of the lens.
void
setVendor(String vendor)
Sets the viewer vendor string.
void
setVerticalAlignment(GvrViewerParams.VerticalAlignmentType verticalAlignment)
Set the vertical alignment strategy.
void
setVerticalDistanceToLensCenter(float verticalDistanceToLensCenter)
Sets the vertical distance to the lens center.
String
toString()
Returns a string containing a concise, human-readable description of this object.
Uri
toUri()
Encodes the current GVR viewer parameters into a Uri.

Inherited Methods

Public Constructors

public GvrViewerParams ()

Initializes GVR viewer parameters to default values for Cardboard v2.

Consider using getGvrViewerParams to access the parameters for the currently paired headset.

public GvrViewerParams (GvrViewerParams params)

Creates a copy of an existing viewer params object.

Parameters
params viewer parameters to copy.

Public Methods

public static GvrViewerParams cardboardV1ViewerParams ()

Sets parameters to Cardboard v1.0.0

public static GvrViewerParams cardboardV2ViewerParams ()

Sets parameters to Cardboard v2.2

public static GvrViewerParams createFromNfcContents (NdefMessage tagContents)

Initializes physical parameters from the contents of a GVR NFC tag.

Parameters
tagContents Contents of the GVR NFC tag.
Returns
  • A new GVR headset parameters object or null in case of error.

public static GvrViewerParams createFromUri (Uri uri)

Initializes the physical parameters of a GVR headset from a Uri.

Parameters
uri Uri to read the parameters from.
Returns

public boolean equals (Object other)

Compares this instance with the specified object and indicates if they are equal.

This is not strictly an equality operator, as it may conservatively return false when the two objects to compare were built from a Protocol buffer.

Parameters
other The object to compare this instance with.
Returns
  • true if the objects are equal, false otherwise.

public Distortion getDistortion ()

Returns the lens distortion model.

Returns
  • The lens distortion model.

public boolean getHasMagnet ()

Returns whether or not the GVR headset has a magnet.

Returns
  • True if a magnet exists, false otherwise.

public float getInterLensDistance ()

Returns the inter lens distance for the viewer.

Returns
  • The inter lens distance in meters.

public FieldOfView getLeftEyeMaxFov ()

Returns the left eye's maximum field of view visible through the lens. The actual rendered field of view will be limited by this and also by the size of the screen. When rendering, a mirrored field of view is expected to be applied to the right eye.

Returns
  • The left eye's maximum field of view.

public String getModel ()

Returns the viewer model string.

Returns
  • A string identifying the viewer model.

public float getScreenToLensDistance ()

Returns the screen to lens distance in meters.

Returns
  • The screen to lens distance in meters.

public String getVendor ()

Returns the viewer vendor string.

Returns
  • A string identifying the viewer vendor.

public GvrViewerParams.VerticalAlignmentType getVerticalAlignment ()

Get the vertical alignment strategy.

public float getVerticalDistanceToLensCenter ()

Returns the vertical distance to the lens center.

Returns
  • The vertical distance to the lens center from the bottom or top edge of the inserted display, measured in meters.

public boolean isDefault ()

public static boolean isGvrUri (Uri uri)

Return true if given URI identifies a GVR viewer.

Parameters
uri

public void setHasMagnet (boolean magnet)

Sets whether this GVR headset has a magnet.

public void setInterLensDistance (float interLensDistance)

Sets the inter lens distance of the viewer.

Parameters
interLensDistance The distance between the center of each lens in meters.

public void setModel (String model)

Sets the viewer model string.

Parameters
model The viewer model string to set.

public void setScreenToLensDistance (float screenToLensDistance)

Sets the distance from the screen to the optical center of the lens.

This value impacts the scale applied when rendering.

Parameters
screenToLensDistance The screen to lens distance in meters.

public void setVendor (String vendor)

Sets the viewer vendor string.

Parameters
vendor The vendor string to set.

public void setVerticalAlignment (GvrViewerParams.VerticalAlignmentType verticalAlignment)

Set the vertical alignment strategy.

Parameters
verticalAlignment

public void setVerticalDistanceToLensCenter (float verticalDistanceToLensCenter)

Sets the vertical distance to the lens center.

Parameters
verticalDistanceToLensCenter The vertical distance from the center of the lenses to the bottom or top edge of the inserted display. Measured in meters.

public String toString ()

Returns a string containing a concise, human-readable description of this object.

Returns
  • A printable representation of this object.

public Uri toUri ()

Encodes the current GVR viewer parameters into a Uri.

The returned Uri can be written into the GVR NFC tag, a file, or encoded in a QR code.

Additional extra parameters can be added to the returned URL by using the Uri.buildUpon() and Uri.Builder.appendQueryParameter(key, value) methods. The parameter key name URI_KEY_PARAMS is reserved.

Returns
  • A Uri encoding the current GVR viewer parameters.