Skip to content

How to get origin SpatialCoordinateSystem using MRTK + OpenXR #10082

@cgsaxner

Description

@cgsaxner

Overview

This documentation states that MRTK provides already marshalled types for getting the SpatialCoordinateSystem through the WindowsMixedRealityUtilities class. However, this class does not seem to contain those members.

With Windows XRSDK, I obtained the origin SpatialCoordinateSystem like this:

      IntPtr WorldOriginPtr =
            UnityEngine.XR.WindowsMR.WindowsMREnvironment.OriginSpatialCoordinateSystem;

        SpatialCoordinateSystem unityWorldOrigin = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(
            WorldOriginPtr) as SpatialCoordinateSystem;

But with the new OpenXR SDK, this is not working anymore. I tried to access the SpatialCoordinateSystem using IWindowsMixedRealityUtilitiesProvider interface:

IntPtr WorldOriginPtrMRTK = 
     MRTK.WindowsMixedReality.WindowsMixedRealityUtilities.UtilitiesProvider.ISpatialCoordinateSystemPtr;

but this throws an exception.

Expected behavior

The underlying SpatialCoordinateSystem can be accessed like

SpatialCoordinateSystem unityWorldOrigin = 
     Microsoft.MixedReality.Toolkit.WindowsMixedReality.WindowsMixedRealityUtilities.SpatialCoordinateSystem

Actual behavior

Microsoft.MixedReality.Toolkit.WindowsMixedReality.WindowsMixedRealityUtilities does not contain a definition for SpatialCoordinateSystem, and other methods do not work with OpenXR SDK.

Unity editor version

Unity 2020.3.13f1

Mixed Reality Toolkit release version

MRTK 2.7.2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions