Google Cardboard Classes

A- CardboardActivity - CardboardActivity is public class and Base activity that provides easy integration with Cardboard devices. Exposes events to interact with Cardboards and handles many of the details commonly required when creating an Activity for VR rendering.
Some public methods-
public boolean areVolumeKeysDisabled () - Tells if the volume keys are currently being disabled by CardboardActivity Note that volume keys can be disabled by other child activities even if this method reports they are not disabled and returns true if the volume keys are currently being disabled by CardboardActivity. Throws IllegalStateException (If the current volume keys mode is invalid).
public CardboardView getCardboardView () - Returns the Cardboard view associated with this activity. Returns the CardboardView object associated with this activity. Can be null.
public int getVolumeKeysMode ()- Provides the current mode for managing the volume keys. and returns a CardboardActivity.VolumeKeys constant defining the current mode for managing the volume keys.
public void onCardboardTrigger ()- Override to detect when the Cardboard trigger was pulled and released. Provides click-like events when the device is inside a Cardboard.
public void setCardboardView (CardboardView cardboardView) - Associates a Cardboard view with this activity. This method does not set or change the content view, but associates the activity with a CardboardView and ensures it receives any required activity lifecycle notifications. This is automatically done if setContentView is used to directly set a CardboardView object. Should be called if the CardboardView is set in any other way (e.g. from a layout resource).
Parameters-
cardboardView- The Cardboard view to associate with. Can be null.
public void setVolumeKeysMode (int mode) - Sets the way in which volume keys should be managed. Volume keys can be accidentally pressed while the device is inserted into a Cardboard. To avoid or reduce this, different modes are provided to disable them.
Parameters-
Mode - One of the VolumeKeys constants defining how the volume keys should be managed.
protected void updateCardboardDeviceParams (CardboardDeviceParams newParams)- Requests an update of the parameters for the current Cardboard device. Compares against existing configuration and updates if the new parameters differ. This method requires a CardboardView to be already set. See setCardboardView.
Parameters-
newParams- New Cardboard device params to set.
B-CardboardActivity.VolumeKeys - Defines the constants with options for managing the volume keys. For use with setVolumeKeysMode.
public static final int DISABLED- Volume keys should be disabled and Constant Value: 1
public static final int NOT_DISABLED- Volume keys should not be disabled and Constant Value: 0
C-CardboardDeviceParams- This is 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.
Public Constructors -
public CardboardDeviceParams () - Initializes Cardboard device parameters to default Cardboard v1.0.0 values. 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 createFromInputStream (InputStream inputStream)- Initializes the physical parameters of a Cardboard device from an InputStream. Caller is responsible for closing stream and returns a new Cardboard device parameters object or null in case of error. Parameters-
inputStream - input stream containing device params.
public static CardboardDeviceParams createFromNfcContents (NdefMessage tagContents)- Initializes physical parameters from the contents of a Cardboard NFC tag and returns a new Cardboard device parameters object or null in case of error.
Parameters-
tagContents- Contents of the Cardboard NFC tag.
public static CardboardDeviceParams createFromUri (Uri uri)- Initializes the physical parameters of a Cardboard device from a Uri and returns new Cardboard device parameters object or null in case of error.
Parameters-
Uri - Uri to read the parameters from.
public boolean equals (Object other)- Compares this instance with the specified object and indicates if they are equal and returns true if the objects are equal, false otherwise.
Parameters-
Other - The object to compare this instance with.
public Distortion getDistortion ()- Returns the lens distortion model and returns the lens distortion model.
public boolean getHasMagnet ()- Returns whether or not the cardboard device has a magnet and returns True if a magnet exists, false otherwise.
public float getInterLensDistance () - Returns the inter lens distance for the device and 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 and returns the left eye's maximum field of view.
public String getModel ()- Returns the device model string and returns a string identifying the device model.
public float getScreenToLensDistance () - Returns the screen to lens distance in meters and returns the screen to lens distance in meters.
public String getVendor ()- Returns the device vendor string and returns a string identifying the device vendor and returns a string identifying the device vendor.
public float getVerticalDistanceToLensCenter ()- Returns the vertical distance to the lens center and returns t he vertical distance to the lens center from the bottom of the inserted device, measured in meters.
public static boolean isCardboardUri (Uri uri)- Return true if given URI identifies a Cardboard device.
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 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 of the inserted device. Measured in meters.
public String toString ()- Returns a string containing a concise, human-readable description of this object and 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() andUri.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 and returns whether the parameters were successfully written.
Parameters-
outputStream- OutputStream in which the parameters are stored.
D- CardboardView- This is a public class, CardboardView Convenience extension of GLSurfaceView that can be used for VR rendering. Designed to work in full screen mode with a landscape or reverse landscape orientation. This view can be used as a normal GLSurfaceView by implementing one of its rendering interfaces:
CardboardView.StereoRenderer: abstracts all stereoscopic rendering details from the renderer. • CardboardView.Renderer: for complex engines that need to handle all stereo rendering details by themselves.
The CardboardView.StereoRenderer interface is recommended for all applications that can make use of it, while the CardboardView.Renderer interface is discouraged and should only be used if really needed. The view allows switching from VR mode to normal rendering mode in stereo renderers at any time by calling thesetVRModeEnabled method.
Interface-
1- CardboardView.Renderer- Interface for renderers who need to handle all the stereo rendering details by themselves.
2- CardboardView.StereoRenderer- Interface for renderers that delegate all stereoscopic rendering details to the view.
Constructors-
CardboardView (Context context)
CardboardView (Context context, AttributeSet attrs)
Public Methods -
public boolean getAlignmentMarkerEnabled ()- Returns whether the alignment marker is drawn. Returns true if the alignment marker is enabled, false otherwise. Enabled by default.
public CardboardDeviceParams getCardboardDeviceParams ()- Returns the physical parameters of the current Cardboard device. This is a convenience method for getHeadMountedDisplay().getCardboardDeviceParams(). Changes to the returned object do not have any affect on rendering. To make them effective use theupdateCardboardDeviceParams method. Returns the physical parameters of the current Cardboard device.
public void getCurrentEyeParams (HeadTransform head, Eye leftEye, Eye rightEye,Eye monocular)- Retrieves the current parameters for each eye. This method is designed for API users that have their own rendering loop and cannot use the standardCardboardView.Renderer and CardboardView.StereoRenderer interfaces. Its use is discouraged for other purposes for performance reasons. If a renderer has been set and a renderer thread is used, this call will block until the renderer thread is able to provide the required data.
Parameters-
Head - Where the head transformation will be written. Cannot be null.
leftEye - Where the left eye parameters will be written, only if VR mode is enabled.
rightEye - Where the right eye parameters will be written, only if VR mode is enabled.
Monocular - Where the monocular parameters will be written, only if VR mode is disabled.
public boolean getDistortionCorrectionEnabled ()- Gets whether distortion correction is enabled. Returns true if distortion correction is enabled, false otherwise.
public HeadMountedDisplay getHeadMountedDisplay ()- Returns the current head mounted display this view is rendering for. Contains various parameters about the screen and Cardboard device that combined make up the head mounted display. Note that changing the returned object will not make any changes to rendering. For that purpose theupdateCardboardDeviceParams and updateScreenParams methods should be used instead. Returns The parameters of the target head mounted display.
public float getInterpupillaryDistance ()- Gets the interpupillary distance. The Cardboard framework currently assumes that user IPD matches inter-lens distance of the viewing device. Returns The current interpupillary distance in meters.
public boolean getRestoreGLStateEnabled ()- Returns whether or not the application's GL state after postprocessing is restored. Returns true if GL state restoration is currently enabled, false otherwise. Enabled by default.
public ScreenParams getScreenParams ()- Returns the screen parameters of the inserted device. This is a convenience method for getHeadMountedDisplay().getScreenParams(). Changes to the returned object do not have any affect on rendering. To make them effective use theupdateScreenParams method. Returns the screen parameters of the inserted device.
public boolean getSettingsButtonEnabled ()- Returns whether the settings button is drawn. Returns true if the settings button is enabled, false otherwise. Enabled by default.
public boolean getVRMode ()- Returns the current VR mode setting. Returns true if VR mode is currently enabled, false otherwise. Enabled by default.
public boolean getVignetteEnabled ()- Returns whether or not vignetting is enabled. Returns true if vignetting is currently enabled, false otherwise. Enabled by default.
public void onPause ()- Informs the view that the activity has been paused.
public void onResume ()- Informs the view that the activity has been resumed.
public void setAlignmentMarkerEnabled (boolean enabled)- Enables or disables drawing a vertical line dividing the viewport in half. This is designed to help users correctly align the cardboard to the screen. Only applies when VR mode is enabled.
Parameters-
Enabled - true to enable drawing the alignment marker, false to disable.
public void setDistortionCorrectionEnabled (boolean enabled)- Sets whether distortion correction is enabled. Enabled by default. Changes will be effective from the first frame after this call. Parameters Enabled - true to enable distortion correction, false to disable.
public void setDistortionCorrectionTextureFormat (int textureFormat, int textureType)- Sets the format of the texture to use for distortion correction.
Parameters-
textureFormat - GL constant describing the texture format in glTexImage2D.
textureType - GL constant describing the texture data type in glTexImage2D.
public void setRenderer (CardboardView.StereoRenderer renderer)- Sets a renderer that delegates all details about stereoscopic rendering to the view. Only one renderer should be set during the entire lifetime of this object. See the StereoRenderer interface for details.
Parameters-
Renderer- Stereo renderer to set.
public void setRenderer (CardboardView.Renderer renderer)- Sets a renderer that handles all stereoscoping rendering details by itself. Only one renderer should be set during the entire lifetime of this object. See the Renderer interface for details.
Parameters-
Renderer- Renderer to set. Cannot be null.
public void setRestoreGLStateEnabled (boolean enabled)- Enables or disables restoration of the application's GL state after postprocessing. CardboardView may perform certain postprocessing steps at the end of each frame. For example, application imagery might be rendered into a texture instead of on-screen. If this flag is enabled, the framework ensures that the GL state at the beginning of the next frame is equivalent to the GL state at the end of the last frame. Enabled by default. If disabled, applications may gain a performance boost but can't make any assumptions about the following subset of the GL state machine at the beginning of each frame:
• Viewport
• Clear color
• Active texture unit
• Shader program that is being used
• Vertex attributes (pointers and whether or not they are enabled)
• Whether GL_CULL_FACE and GL_SCISSOR_TEST are enabled
• Bindings for GL_ARRAY_BUFFER and GL_ELEMENT_ARRAY_BUFFER
• Binding for GL_TEXTURE_2D in texture unit 0
There are two exceptions:
1. The currently bound frame buffer will always be restored, regardless of the state of this setting.
2. Vertex attribute bindings are never restored. Any calls to glVertexAttribPointer at the end of last frame will not be in effect anymore at the beginning of next frame.
Parameters-
Enable - true to enable GL state restoration, false to disable.
public void setSettingsButtonEnabled (boolean enabled)- Enables or disables drawing a settings button at the bottom center of the screen. Tapping the button sends the user to the Google Cardboard app where they can configure user parameters and Cardboard viewer parameters. The configuration will automatically apply to all of the user's apps that are using the vrtoolkit. Only applies when VR mode is enabled.
Parameters-
enabled - true to enable drawing the settings button, false to disable.
public void setVRModeEnabled (boolean enabled)- Enables or disables VR rendering mode. Controls stereo rendering and distortion correction. Enabled by default. Changes will be effective from the first frame after this call. If disabled, no interpupillary distance will be applied to the eye transformations and automatic distortion correction will not take place. Changes will be applied to the next frames being drawn. See the documentation of the Renderer and StereoRenderer interfaces for details on how they are affected by VR mode.
Parameters-
enabled - true to enable VR mode, false to disable.
public void setVignetteEnabled (boolean enabled)- Enables or disables vignetting around the frame edge. If this flag is enabled, the distortion shader applies a darkening effect to the edges of the visible viewport, simulating vignetting. Enabled by default.
Parameters-
Enabled - true to enable vignette effect, false to disable.
public void undistortTexture (int inputTexture)- Undistorts the provided texture by rendering into the current output buffer. This method is designed for API users that have their own rendering loop and cannot use the standardCardboardView.Renderer and CardboardView.StereoRenderer interfaces. Its use is discouraged for other purposes. If a renderer has been set, texture undistortion will take place in the renderer thread. Otherwise the operation will happen in the calling thread. It is the responsibility of the caller to ensure the validity of the texture in the GL context of the thread where is used.
Parameters-
inputTexture- Texture name to undistort.
public void updateCardboardDeviceParams (CardboardDeviceParams cardboardDeviceParams)- Updates the physical parameters of the Cardboard device used for rendering. Changes will be effective from the first frame after this call.
Parameters-
cardboardDeviceParams - Physical parameters of a Cardboard-compatible device. Ignores the request if the object is null or same as current.
public void updateScreenParams (ScreenParams screenParams)- Updates the screen parameters used for rendering. Updates the screen parameters of the device inserted in the Cardboard. Changes will be effective from the first frame after this call.
Parameters-
screenParams - Parameters to update. Ignored if null.
E- Constants -Static class containing useful constants. public static final String CARDBOARD_CATEGORY Apps that use vrtoolkit should include this category (along with action MAIN) in their AndroidManifest.xml. An Activity tagged with this category will show up in the list of Cardboard apps in the Cardboard launcher.
Example -
intent filter: Constant Value: "com.google.intent.category.CARDBOARD"
public static final String VERSION - The vrtoolkit version. Constant Value: "0.5.0"
F- Distortion- This is public class Distortion. Defines all required parameters to correct the distortion caused by the lenses.
Public Constructors -
public Distortion ()
public Distortion (Distortion other)- Constructs a copy of another distortion object.
Parameters-
Other - The distortion object to copy from.
Public Methods-
public float distort (float radius)- Distorts a radius by its distortion factor from the center of the lenses. Returns the distorted radius in tan-angle units.
Parameters-
Radius - Radius from the lens center in tan-angle units.
public float distortInverse (float radius)- Calculates the inverse distortion for a radius. Allows to compute the original undistorted radius from a distorted one. See also getApproximateInverseDistortion() for a faster but potentially less accurate method. Returns The undistorted radius in tan-angle units. 
Parameters-
Radius - Distorted radius from the lens center in tan-angle units.
public float distortionFactor (float radius)- Returns the distortion factor of a point. Returns The distortion factor. Multiply by this factor to distort points.
Parameters -
radius - Radius of the point from the lens center in tan-angle units.
public boolean equals (Object other)- Compares this instance with the specified object and indicates if they are equal. Returns true if the objects are equal, false otherwise.
Parameters-
other - The object to compare this instance with.
public Distortion getApproximateInverseDistortion (float maxRadius)- Builds an inverse-distortion object with least-squares-fitted coefficients. This is intended for implementing application-side custom distortion. Use .getCoefficients() on the returned object to retrieve the inverse distortion function's coefficients. This is an approximate inverse, and using .distort() on the returned object will be faster but less accurate than using the distortInverse() method on the original. For useful results, the input distortion must be well-behaved in the 0..maxRadius range. Returns New distortion object. Parameters-
maxRadius - Maximum supported radius in tan-angle units. Should be set to match the maximum expected field of view angle.
public float[] getCoefficients ()-Returns the current coefficients for lens distortion correction. Returns A floating point array with the current barrel distortion coefficients.
public void setCoefficients (float[] coefficients)- Sets the coefficients for lens distortion correction. The coefficients Ki correspond to the pincushion distortion equation:
p' = p (1 + K1 r^2 + K2 r^4 + ... + Kn r^(2n))
Where r is the distance from the optical center, p the input point and p' the output point.
Parameters-
coefficients - Barrel distortion coefficients to set.
public String toString ()- Returns a string containing a concise, human-readable description of this object. Returns a printable representation of this object.
G- DistortionRenderer- public class DistortionRenderer Encapsulates the rendering operations to correct lens distortion. This class is not thread-safe. For performance reasons, exposed public methods in this class are assumed to run in mutual exclusion (e.g. in the same or non-overlapping threads).
Public Constructors-
public DistortionRenderer ()
Public Methods-
public void afterDrawFrame ()- Performs distortion correction. Must be called after drawing a frame to correct its distortion. Note that this method is only allowed to modify the parts of the OpenGL state machine which are backed up and restored using a GLStateBackup object.
public void beforeDrawFrame ()- Performs the required setup to correct distortion. Must be called before drawing a frame that should be undistorted.
public boolean haveViewportsChanged ()- Checks if the distortion-corrected dimensions of the viewports have changed since the last call to updateViewports. Returns true if the dimensions have changed, false otherwise.
public void onFovChanged (HeadMountedDisplay hmd, FieldOfView leftFov,FieldOfView rightFov, float virtualEyeToScreenDistance)- To be called when a change in the field of view of any eye happens. Must be called at least once prior to beforeDrawFrame(). Calling this method between beforeDrawFrame() andafterDrawFrame() calls will raise an IllegalStateException. This method might recompute the mesh used for distortion correction, but no changes involving GL calls will take place until beforeDrawFrame() is called.
Parameters-
Hmd - The head mounted display.
leftFov - The field of view of the left eye.
rightFov - The field of view of the right eye.
virtualEyeToScreenDistance - The virtual-eye-to-screen distance in meters.
public void setRestoreGLStateEnabled (boolean enabled)- Enables or disables restoration of the application's GL state after postprocessing. If this flag is enabled, the framework ensures that the GL state at the beginning of the next frame is equivalent to the GL state at the end of the last frame. Enabled by default.
Parameters-
Enabled - true to enable GL state restoration, false to disable.
public void setTextureFormat (int textureFormat, int textureType)- Sets the format of the texture to use for distortion correction. Calling this method between beforeDrawFrame() and afterDrawFrame() calls will raise anIllegalStateException.
Parameters-
textureFormat- GL constant describing the texture format in glTexImage2D.
textureType- GL constant describing the texture data type in glTexImage2D.
public void setVignetteEnabled (boolean enabled)- Enables or disables vignetting around frame edge. If this flag is enabled, the distortion shader applies a darkening effect to the edges of the visible viewport, simulating vignetting. Enabled by default.
Parameters-
Enabled - true to enable vignette effect, false to disable.
public void undistortTexture (int textureId)- Undistorts the provided texture by rendering into the current output target.
Parameters-
textureId - Texture to undistort.
public void updateViewports (Viewport leftViewport, Viewport rightViewport)- Updates the eye viewports to their effective dimensions after distortion correction.
Parameters-
leftViewport - Object updated with the viewport for the left eye.
rightViewport - Object updated with the viewport for the right eye.
H- Eye-This is public class Eye Describes the stereoscopic rendering details of an eye.
Public Constructors-
public Eye (int type)- Creates a new set of eye parameters.
Parameters- 
Type - One of the Eye.Type constants describing the eye this object refers to. Behavior is undefined if an invalid eye constant is provided.
Public Methods-
public float[] getEyeView ()- Returns a matrix that transforms from the camera to the current eye. This matrix should premultiply the camera matrix. Assumes a scale of 1 world unit = 1 meter when applying the interpupillary distance. If this not your case, make sure to call android.opengl.Matrix.scaleM on this matrix to correct it. The transformation includes head tracking rotation, position shift and interpupillary distance shift. Use this if you just want to get an eye view from your normal view. Returns  A 4x4 column-major representing the transformation from the camera to this eye.
public FieldOfView getFov ()- Returns the field of view for this eye. Use the getFov().toPerspectiveMatrix method to generate the appropriate perspective projection matrix to use. Returns the field of view for this eye.
public float[] getPerspective (float zNear, float zFar)- Convenience method that returns the perspective projection matrix for this eye. Calls getFov().toPerspectiveMatrix to generate the perspective matrix to use. Returns a 4x4 column-major matrix representing the perspective projection for this eye.
Parameters-
zNear - Near Z plane to use in the projection.
zFar - Far Z plane to use in the projection.
public int getType ()- Returns the eye type this object refers to. Returns the current eye as one of the Eye.Type constants.
public Viewport getViewport ()- Returns the viewport for this eye. Returns viewport to use when rendering this eye.
public void setProjectionChanged ()- Forces to clean up any cached projection matrices. Called by the framework when projection parameters change between frames. Should be called if the eye's field of view object returned by getFov() is changed.

Delhi, INDIA

0 comments: