Google cardBoard Android API (二):CardboardDeviceParams

18 篇文章 0 订阅
18 篇文章 0 订阅
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

Public Methods

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.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值