Open 3D Engine OpenXRVk Gem API Reference 25.05.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
OpenXRVk::IOpenXRReferenceSpaces Class Referenceabstract

#include <OpenXRVkReferenceSpacesInterface.h>

Public Types

using ReferenceSpaceId = uint32_t
 

Public Member Functions

 AZ_RTTI (IOpenXRReferenceSpaces, "{244D24BE-DD6F-430A-8F99-1D24AC1665B6}")
 
 AZ_DISABLE_COPY_MOVE (IOpenXRReferenceSpaces)
 
virtual AZStd::vector< AZStd::string > GetReferenceSpaceNames () const =0
 
virtual AZ::Outcome< bool, AZStd::string > AddReferenceSpace (ReferenceSpaceId referenceSpaceType, const AZStd::string &spaceName, const AZ::Transform &poseInReferenceSpace)=0
 
virtual AZ::Outcome< bool, AZStd::string > RemoveReferenceSpace (const AZStd::string &spaceName)=0
 
virtual const void * GetReferenceSpaceNativeHandle (const AZStd::string &spaceName) const =0
 
virtual AZ::Outcome< AZ::Transform, AZStd::string > GetReferenceSpacePose (const AZStd::string &spaceName, const AZStd::string &baseSpaceName) const =0
 
virtual AZ::Outcome< bool, AZStd::string > SetBaseSpaceForViewSpacePose (const AZStd::string &spaceName)=0
 
virtual const AZStd::string & GetBaseSpaceForViewSpacePose () const =0
 
virtual const AZ::Transform & GetViewSpacePose () const =0
 
virtual uint32_t GetViewCount () const =0
 
virtual const AZ::Transform & GetViewPose (uint32_t eyeIndex) const =0
 
virtual const AZ::RPI::FovData & GetViewFovData (uint32_t eyeIndex) const =0
 Returns the FovData for a particular View (aka Eye).
 
virtual const AZStd::vector< AZ::Transform > & GetViewPoses () const =0
 
virtual void ForceViewPosesCacheUpdate ()=0
 

Static Public Attributes

static constexpr ReferenceSpaceId ReferenceSpaceIdView = 1
 
static constexpr ReferenceSpaceId ReferenceSpaceIdLocal = 2
 
static constexpr ReferenceSpaceId ReferenceSpaceIdStage = 3
 
static constexpr char ReferenceSpaceNameView [] = "View"
 
static constexpr char ReferenceSpaceNameLocal [] = "Local"
 
static constexpr char ReferenceSpaceNameStage [] = "Stage"
 
static constexpr uint32_t LeftEyeView = 0
 Useful constants for OpenXR Stereo systems.
 
static constexpr uint32_t RightEyeView = 1
 

Detailed Description

REMARK: This class must be instantiated BEFORE OpenXRActionsInterface. To know more about OpenXR Reference Spaces, see the spec: https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#spaces This interface consolidates the API that works with definition of Reference Spaces and retreival of their Poses as AZ::Transforms.

Member Function Documentation

◆ AddReferenceSpace()

virtual AZ::Outcome< bool, AZStd::string > OpenXRVk::IOpenXRReferenceSpaces::AddReferenceSpace ( ReferenceSpaceId  referenceSpaceType,
const AZStd::string &  spaceName,
const AZ::Transform &  poseInReferenceSpace 
)
pure virtual

Creates a new Reference Space, and the developer will define what name they want to use to address the new space.

Parameters
referenceSpaceTypeAn integral, that identifies a system reference space, that will be used as anchor reference for the new space that will be created. The caller can use other integrals, different than the three constants mentioned above, but the caller would need to verify on their own that said system reference space is supported by the OpenXR Runtime they are working with. OpenXR only guarantess that View, Local and Stage are always supported.
spaceNameName of the new space, and must be different than any other reference space previously created.
poseInReferenceSpaceA transform that defines the default orientation and position of the new space, relative to the system reference space defined by @referenceSpaceType.
Returns
Success if the space name is unique, and the @referenceSpaceType space id is supported by the runtime. In case of failure, an error description is provided.

◆ ForceViewPosesCacheUpdate()

virtual void OpenXRVk::IOpenXRReferenceSpaces::ForceViewPosesCacheUpdate ( )
pure virtual

Forces updating the cached pose and projection data for all Views (Eyes). Each frame, all view (aka eye) poses and projections are updated automatically, making this function optional to use. By default the caller simply gets the per-frame cached version, which should be fine for most applications. This API was added because according to OpenXR xrLocateViews spec: "Repeatedly calling xrLocateViews with the same time may not necessarily return the same result. Instead the prediction gets increasingly accurate as the function is called closer to the given time for which a prediction is made".

◆ GetBaseSpaceForViewSpacePose()

virtual const AZStd::string & OpenXRVk::IOpenXRReferenceSpaces::GetBaseSpaceForViewSpacePose ( ) const
pure virtual

Returns the name of the current Reference Space that is used as base reference space when locating the "View" reference space.

◆ GetReferenceSpaceNames()

virtual AZStd::vector< AZStd::string > OpenXRVk::IOpenXRReferenceSpaces::GetReferenceSpaceNames ( ) const
pure virtual
Returns
a list of strings, Where each string is the name of each active reference space. The session will always instantiate the three reference spaces mentioned above: View, Local and Stage. So this list will always contain at least three strings.

◆ GetReferenceSpaceNativeHandle()

virtual const void * OpenXRVk::IOpenXRReferenceSpaces::GetReferenceSpaceNativeHandle ( const AZStd::string &  spaceName) const
pure virtual

REMARK: Maybe it's a good idea to move this into a private interface for the OpenXRVk Gem, and privately use the native handle (XrSpace)

◆ GetReferenceSpacePose()

virtual AZ::Outcome< AZ::Transform, AZStd::string > OpenXRVk::IOpenXRReferenceSpaces::GetReferenceSpacePose ( const AZStd::string &  spaceName,
const AZStd::string &  baseSpaceName 
) const
pure virtual

Returns the Pose of @spaceName relative to @baseSpaceName. This function is typically called within the game loop to poll/query the current pose of a particular reference space, relative to another reference space.

Parameters
spaceNameThe name of the reference space whose Transform the caller needs to know.
baseSpaceNameThe name of the base reference space that the OpenXR runtime will use to calculate a relative Transform.
Returns
If successful, a Transform that defines the pose of @spaceName, relative to @baseSpaceName.

◆ GetViewCount()

virtual uint32_t OpenXRVk::IOpenXRReferenceSpaces::GetViewCount ( ) const
pure virtual

For an AR application running on a Phone (Mono) the count will be 1. For an AR/VR application running on a typical headset (Stereo) the count will be 2. Some headsets like the Varjo support Quad Views and the eye (view) counts will be 4.

◆ GetViewPose()

virtual const AZ::Transform & OpenXRVk::IOpenXRReferenceSpaces::GetViewPose ( uint32_t  eyeIndex) const
pure virtual

Pose of a view(aka eye) relative to the View Space (aka Head) Pose. For AR applications running on a Phone (aka Mono view configuration) the Eye View Pose is centered exactly where the View Space Centroid is located, so calling this function wouldn't make much sense because it'll return an Identity transform.

Remarks
DO NOT CONFUSE View Pose with "View" Space Pose. This is a confusing aspect of the OpenXR API. It is tempting to call this function as GetEyePose.

◆ GetViewPoses()

virtual const AZStd::vector< AZ::Transform > & OpenXRVk::IOpenXRReferenceSpaces::GetViewPoses ( ) const
pure virtual

A convenient method that returns the relative pose of all Views (aka Eyes) relative to the "View" Reference Space, which typically represents the user's head centroid.

◆ GetViewSpacePose()

virtual const AZ::Transform & OpenXRVk::IOpenXRReferenceSpaces::GetViewSpacePose ( ) const
pure virtual
Returns
The per-frame "calculated and cached" Pose of the "View" Reference Space.
Remarks
This same Pose is also reported automatically, each frame, via the AZ::RPI::XRSpaceNotificationBus. Also the returned Pose is a Transform relative to the base Reference Space defined via SetBaseSpaceForViewSpacePose().

◆ RemoveReferenceSpace()

virtual AZ::Outcome< bool, AZStd::string > OpenXRVk::IOpenXRReferenceSpaces::RemoveReferenceSpace ( const AZStd::string &  spaceName)
pure virtual

Removes a previously user-created reference space.

Parameters
spaceNameThe name of the reference space to remove.
Returns
Success if a reference space with said name exists and it is NOT one of "View", "Local" or "Stage".

◆ SetBaseSpaceForViewSpacePose()

virtual AZ::Outcome< bool, AZStd::string > OpenXRVk::IOpenXRReferenceSpaces::SetBaseSpaceForViewSpacePose ( const AZStd::string &  spaceName)
pure virtual

With this method the caller defines the base reference space that will be used each frame to locate the "View" reference space. Each frame, The "View" reference space is the only reference space that will be automatically located, and its pose will be internally cached. The located pose will always be relative to the @spaceName defined the last time this method was called. If this method is never called, the runtime will default to the "Local" reference spaces as the base reference space that will be used to locate the "View" reference space. This is a stateful API, you only need to call this method once, or as needed. Each time GetViewSpacePose() is called, the returned Transform will be relative to @spaceName

Parameters
spaceNameThe name of the base reference space that will be used to caculate the pose of the View space.
Remarks
Typically, the "View" reference space represents the User's head centroid. Internally, the Pose for each Eye View will be calculated relative to the View Space centroid and it will be reported via the notification bus: AZ::RPI::XRSpaceNotificationBus

The documentation for this class was generated from the following file: