ARVRInterface

Inherits: Reference < Object

Inherited By: ARVRInterfaceGDNative, MobileVRInterface

Category: Core

Brief Description

Base class for ARVR interface implementation.

Member Variables

  • bool ar_is_anchor_detection_enabled - On an AR interface, is our anchor detection enabled?
  • bool interface_is_initialized - Has this interface been initialized?
  • bool interface_is_primary - Is this our primary interface?

Numeric Constants

  • ARVR_NONE = 0 — No ARVR capabilities.
  • ARVR_MONO = 1 — This interface can work with normal rendering output (non-HMD based AR).
  • ARVR_STEREO = 2 — This interface supports stereoscopic rendering.
  • ARVR_AR = 4 — This interface support AR (video background and real world tracking).
  • ARVR_EXTERNAL = 8 — This interface outputs to an external device, if the main viewport is used the on screen output is an unmodified buffer of either the left or right eye (stretched if the viewport size is not changed to the same aspect ratio of get_render_targetsize. Using a seperate viewport node frees up the main viewport for other purposes.
  • EYE_MONO = 0 — Mono output, this is mostly used internally when retrieving positioning information for our camera node or when stereo scopic rendering is not supported.
  • EYE_LEFT = 1 — Left eye output, this is mostly used internally when rendering the image for the left eye and obtaining positioning and projection information.
  • EYE_RIGHT = 2 — Right eye output, this is mostly used internally when rendering the image for the right eye and obtaining positioning and projection information.
  • ARVR_NORMAL_TRACKING = 0 — Tracking is behaving as expected.
  • ARVR_EXCESSIVE_MOTION = 1 — Tracking is hindered by excessive motion, player is moving faster then tracking can keep up.
  • ARVR_INSUFFICIENT_FEATURES = 2 — Tracking is hindered by insufficient features, it’s too dark (for camera based tracking), player is blocked, etc.
  • ARVR_UNKNOWN_TRACKING = 3 — We don’t know the status of the tracking or this interface does not provide feedback.
  • ARVR_NOT_TRACKING = 4 — Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.)

Description

This class needs to be implemented to make an AR or VR platform available to Godot and these should be implemented as C++ modules or GDNative modules (note that for GDNative the subclass ARVRScriptInterface should be used). Part of the interface is exposed to GDScript so you can detect, enable and configure an AR or VR platform.

Interfaces should be written in such a way that simply enabling them will give us a working setup. You can query the available interfaces through ARVRServer.

Member Function Description

  • int get_capabilities ( ) const

Returns a combination of flags providing information about the capabilities of this interface.

Returns the name of this interface (OpenVR, OpenHMD, ARKit, etc).

  • Vector2 get_render_targetsize ( )

Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.

  • int get_tracking_status ( ) const

If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking.

  • bool initialize ( )

Call this to initialize this interface. The first interface that is initialized is identified as the primary interface and it will be used for rendering output.

After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.

Note that you must enable the AR/VR mode on the main viewport for any device that uses the main output of Godot such as for mobile VR.

If you do this for a platform that handles its own output (such as OpenVR) Godot will show just one eye without distortion on screen. Alternatively you can add a separate viewport node to your scene and enable AR/VR on that viewport and it will be used to output to the HMD leaving you free to do anything you like in the main window such as using a separate camera as a spectator camera or render out something completely different.

While currently not used you can activate additional interfaces, you may wish to do this if you want to track controllers from other platforms. However at this point in time only one interface can render to an HMD.

  • bool is_stereo ( )

Returns true if the current output of this interface is in stereo.

  • void uninitialize ( )

Turns the interface off.