Google cardBoard Android API (二):CardboardDeviceParams

public class CardboardDeviceParams

Defines the physical parameters of a Cardboard-compatible device.

The model assumes the following for any Cardboard device:

  1. Lenses are parallel to the screen of the inserted device.
  2. The center of each lens is at the same height from the bottom of the inserted device.
  3. Lenses are symmetrically placed with respect to the center of the inserted device 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 devices or lenses. For simplicity, they can be stored in the NFC tag of the Cardboard.

Nested Classes

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

Public Constructors

CardboardDeviceParams()
CardboardDeviceParams( CardboardDeviceParams params)

Public Methods

static CardboardDeviceParams
cardboardV1DeviceParams()
static CardboardDeviceParams
createFromInputStream(InputStream inputStream)
static CardboardDeviceParams
createFromNfcContents(NdefMessage tagContents)
static CardboardDeviceParams
createFromUri(Uri uri)
boolean
equals(Object other)
Distortion
getDistortion()
boolean
getHasMagnet()
float
getInterLensDistance()
FieldOfView
getLeftEyeMaxFov()
String
getModel()
float
getScreenToLensDistance()
String
getVendor()
CardboardDeviceParams.VerticalAlignmentType
getVerticalAlignment()
float
getVerticalDistanceToLensCenter()
static boolean
isCardboardUri(Uri uri)
boolean
isDefault()
void
setHasMagnet(boolean magnet)
void
setInterLensDistance(float interLensDistance)
void
setModel(String model)
void
setScreenToLensDistance(float screenToLensDistance)
void
setVendor(String vendor)
void
setVerticalAlignment(CardboardDeviceParams.VerticalAlignmentTypeverticalAlignment)
void
setVerticalDistanceToLensCenter(float verticalDistanceToLensCenter)
String
toString()
Uri
toUri()
boolean
writeToOutputStream(OutputStream outputStream)

Inherited Methods

Public Constructors

public CardboardDeviceParams ()

Initializes Cardboard device parameters to default values for Cardboard v2.

Consider using  HeadMountedDisplayManager to access Cardboard devices parameters more optimized for your headset.

public CardboardDeviceParams (CardboardDeviceParams params)

Creates a copy of an existing device params object.

Parameters
params Device parameters to copy.

Public Methods

public static CardboardDeviceParams cardboardV1DeviceParams ()

Sets parameters to Cardboard v1.0.0

public static CardboardDeviceParams createFromInputStream (InputStreaminputStream)

Initializes the physical parameters of a Cardboard device from an InputStream.

Caller is responsible for closing stream.

Parameters
inputStream input stream containing device params.
Returns
  • A new Cardboard device parameters object or null in case of error.

public static CardboardDeviceParams createFromNfcContents (NdefMessage tagContents)

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

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

public static CardboardDeviceParams createFromUri (Uri uri)

Initializes the physical parameters of a Cardboard device from a Uri.

Parameters
uri Uri to read the parameters from.
Returns
  • A new Cardboard device parameters object or null in case of error.

public boolean equals (Object other)

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

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 cardboard device has a magnet.

Returns
  • True if a magnet exists, false otherwise.

public float getInterLensDistance ()

Returns the inter lens distance for the device.

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 device model string.

Returns
  • A string identifying the device 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 device vendor string.

Returns
  • A string identifying the device vendor.

public CardboardDeviceParams.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 device, measured in meters.

public static boolean isCardboardUri (Uri uri)

Return true if given URI identifies a Cardboard device.

public boolean isDefault ()

public void setHasMagnet (boolean magnet)

Sets whether this cardboard device has a magnet.

public void setInterLensDistance (float interLensDistance)

Sets the inter lens distance of the device.

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

public void setModel (String model)

Sets the device model string.

Parameters
model The device 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 the scale applied when rendering.

Parameters
screenToLensDistance The screen to lens distance in meters.

public void setVendor (String vendor)

Sets the device vendor string.

Parameters
vendor The vendor string to set.

public void setVerticalAlignment (CardboardDeviceParams.VerticalAlignmentTypeverticalAlignment)

Set the vertical alignment strategy.

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 device. 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 Cardboard device parameters into a Uri.

The returned Uri can be written into the Cardboard 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 Cardboard device parameters.

public boolean writeToOutputStream (OutputStream outputStream)

Attempts to write the parameters into the given output stream.

Caller is responsible for closing stream.

Parameters
outputStream OutputStream in which the parameters are stored.
Returns
  • whether the parameters were successfully written.

你可能感兴趣的:(Google cardBoard Android API (二):CardboardDeviceParams)