November 6, 2019 update:
  • There's a new open source Cardboard SDK for iOS and Android NDK that offers a streamlined API, improved device compatibility, and built-in viewer profile QR code scanning. A corresponding Unity package (SDK) is planned for a future release. We recommend that all developers actively building for Google Cardboard migrate (iOS, Android NDK) to the new Cardboard SDK.
October 15, 2019 update:
  • The Daydream View VR headset is no longer available for purchase. However, you can continue to use the existing Google VR SDK to update and distribute your apps to the Google Play Store, and make them available to users in the Daydream app.

FieldOfView

public class FieldOfView

Encapsulates a field of view composed of 4 half angles (left, right, bottom, top) as would be passed to glFrustum.

Public Constructors

FieldOfView(float left, float right, float bottom, float top)
Creates a new field of view object with the provided params.
FieldOfView(FieldOfView other)
Constructs a new field of view object copying the contents from another.

Public Methods

static FieldOfView
cardboardV1FieldOfView()
Returns parameters for Cardboard V1.0.0
void
copy(FieldOfView other)
Copies the contents of another FieldOfView into this one.
boolean
equals(Object other)
Compares this instance with the specified object and indicates if they are equal.
float
getBottom()
Returns the bottom field of view half-angle in degrees.
float
getLeft()
Returns the left field of view half-angle in degrees.
float
getRight()
Returns the right field of view half-angle in degrees.
float
getTop()
Returns the top field of view half-angle in degrees.
void
setAngles(float left, float right, float bottom, float top)
Sets the four half-angles of the field of view.
void
setBottom(float bottom)
Sets the bottom field of view half-angle in degrees.
void
setLeft(float left)
Sets the left field of view half-angle in degrees.
void
setRight(float right)
Sets the right field of view half-angle in degrees.
void
setTop(float top)
Sets the top field of view half-angle in degrees.
void
toPerspectiveMatrix(float near, float far, float[] perspective, int offset)
Generates a perspective projection matrix from this object.
String
toString()
Returns a string containing a concise, human-readable description of this object.

Inherited Methods

Public Constructors

public FieldOfView ()

public FieldOfView (float left, float right, float bottom, float top)

Creates a new field of view object with the provided params.

Parameters
left The left field of view half-angle in degrees.
right The right field of view half-angle in degrees.
bottom The bottom field of view half-angle in degrees.
top The top field of view half-angle in degrees.

public FieldOfView (FieldOfView other)

Constructs a new field of view object copying the contents from another.

Parameters
other The other FieldOfView to copy from.

Public Methods

public static FieldOfView cardboardV1FieldOfView ()

Returns parameters for Cardboard V1.0.0

public void copy (FieldOfView other)

Copies the contents of another FieldOfView into this one.

Parameters
other The FieldOfView object to copy from.

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 float getBottom ()

Returns the bottom field of view half-angle in degrees.

Returns
  • The bottom field of view half-angle in degrees.

public float getLeft ()

Returns the left field of view half-angle in degrees.

Returns
  • The left field of view half-angle in degrees.

public float getRight ()

Returns the right field of view half-angle in degrees.

Returns
  • The right field of view half-angle in degrees.

public float getTop ()

Returns the top field of view half-angle in degrees.

Returns
  • The top field of view half-angle in degrees.

public void setAngles (float left, float right, float bottom, float top)

Sets the four half-angles of the field of view.

Parameters
left The left field of view half-angle in degrees.
right The right field of view half-angle in degrees.
bottom The bottom field of view half-angle in degrees.
top The top field of view half-angle in degrees.

public void setBottom (float bottom)

Sets the bottom field of view half-angle in degrees.

Parameters
bottom The bottom field of view half-angle in degrees.

public void setLeft (float left)

Sets the left field of view half-angle in degrees.

Parameters
left The left field of view half-angle in degrees.

public void setRight (float right)

Sets the right field of view half-angle in degrees.

Parameters
right The right field of view half-angle in degrees.

public void setTop (float top)

Sets the top field of view half-angle in degrees.

Parameters
top The top field of view half-angle in degrees.

public void toPerspectiveMatrix (float near, float far, float[] perspective, int offset)

Generates a perspective projection matrix from this object.

Parameters
near The near plane.
far The far plane.
perspective The perspective matrix to fill.
offset The offset into the perspective array to write the matrix to.
Throws
IllegalArgumentException If there is not enough space to write the result.

public String toString ()

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

Returns
  • A printable representation of this object.