VrWidgetView

public abstract class VrWidgetView
Known Direct Subclasses

Base class for VR Views (Experimental API).

Handles life-cycle management and transitions to different display modes (fullscreen, fullscreen VR, embedded).

When using subclasses of this class, make sure to call the following functions in your code pauseRendering(), resumeRendering(), shutdown(). Refer to documentation for each for further details.

Nested Classes

class VrWidgetView.DisplayMode Holds constants describing how the VR View is rendered on the screen. 

Inherited Constants

Inherited Fields

Public Constructors

Public Methods

int
getDisplayMode()
Returns the current VrWidgetView.DisplayMode.
void
getHeadRotation(float[] yawAndPitch)
Provides yaw and pitch angles corresponding to where the user is looking.
void
pauseRendering()
Pauses 3D rendering and tracking.
void
resumeRendering()
Resumes 3D rendering and tracking.
void
setDisplayMode(int newDisplayMode)
Programmatically updates the VrWidgetView.DisplayMode of the VR View to simulate pressing one of the UI buttons.
void
setFullscreenButtonEnabled(boolean enabled)
Shows or hides the button to transition to fullscreen mode.
void
setInfoButtonEnabled(boolean enabled)
Shows or hides the info button which is normally visible in embed or fullscreen mono modes.
void
setStereoModeButtonEnabled(boolean enabled)
Shows or hides the button to transition to stereo mode.
void
setTouchTrackingEnabled(boolean enabled)
Enables or disabled tracking of the view via touch gestures.
void
setTransitionViewEnabled(boolean enabled)
Shows or hides the transition view used to prompt the user to place their phone into a GVR viewer.
void
shutdown()
Shuts rendering down and releases associated memory.

Inherited Methods

Public Constructors

public VrWidgetView (Context context, AttributeSet attrs)

Parameters
context Context must be an instance of activity, otherwise a Runtime exception is thrown.
attrs Custom attributes for the view.

public VrWidgetView (Context context)

Parameters
context Context must be an instance of activity, otherwise a Runtime exception is thrown.

Public Methods

public int getDisplayMode ()

Returns the current VrWidgetView.DisplayMode.

Returns

public void getHeadRotation (float[] yawAndPitch)

Provides yaw and pitch angles corresponding to where the user is looking.

yaw is the rotation along the vertical (y) axis. Values are in the [-180, 180] range with

  • 0 == looking straight at the initial image orientation
  • 90 == looking 90 degrees to the right
  • -90 == looking 90 degrees to the left
  • 180 == -180 == looking in the direction opposite to the initial one

pitch is the rotation along the right (x) axis previously rotated by yaw. Values are in the [-90, 90] range with

  • 0 == looking straight, level with the ground
  • 90 == looking up
  • -90 == looking down

When pitch approaches 90 or -90, yaw values are reset to zero as computing the yaw values becomes numerically unstable.

Parameters
yawAndPitch Array where the 2 angles will be written to.
Throws
IllegalArgumentException If the size of the given array is less than 2.

public void pauseRendering ()

Pauses 3D rendering and tracking.

This should be called in the activity's onPause() method.

public void resumeRendering ()

Resumes 3D rendering and tracking.

This should be called in the activity's onResume() method.

public void setDisplayMode (int newDisplayMode)

Programmatically updates the VrWidgetView.DisplayMode of the VR View to simulate pressing one of the UI buttons.

Parameters
newDisplayMode The new display mode represented by one of the VrWidgetView.DisplayMode constants.

public void setFullscreenButtonEnabled (boolean enabled)

Shows or hides the button to transition to fullscreen mode. This button is visible by default whenever the View is in embedded or in stereo mode.

Parameters
enabled Whether the button is VISIBLE or GONE.

public void setInfoButtonEnabled (boolean enabled)

Shows or hides the info button which is normally visible in embed or fullscreen mono modes.

Parameters
enabled Whether the info button is VISIBLE or GONE.

public void setStereoModeButtonEnabled (boolean enabled)

Shows or hides the button to transition to stereo mode. This button is visible by default whenever the View is in embedded or fullscreen mode. This button will never be shown on phones which don't have the necessary sensors for stereo mode -- i.e. a gyroscope and accelerometer.

Parameters
enabled Whether the button is VISIBLE or GONE.

public void setTouchTrackingEnabled (boolean enabled)

Enables or disabled tracking of the view via touch gestures. Only the heading angle can be controlled by touch. This is true by default.

Regardless of how this is set, touch tracking will be inactive in fullscreen stereo mode.

Parameters
enabled Whether touch panning is enabled.

public void setTransitionViewEnabled (boolean enabled)

Shows or hides the transition view used to prompt the user to place their phone into a GVR viewer. This is enabled by default.

Parameters
enabled whether to show the transition view.

public void shutdown ()

Shuts rendering down and releases associated memory.

Make sure you call this method before the activity is destroyed to reclaim memory. This can be typically called in the activity's onDestroy() method. pauseRendering() must be called prior to this function.

The View should not be used anymore after this has been called.