Skip to content

How to access the native GlobalCoordinateSystem pointer with OpenXR #10259

@Audenrith

Description

@Audenrith

Before Unity 2019.3, one has been able to access the native pointer to the world SpatialCoordinateSystem via UnityEngine.XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr().
Switching to Unity 2019 one is able to access the same pointer via UnityEngine.XR.WindowsMR.WindowsMREnvironment.OriginSpatialCoordinateSystem using the Windows Mixed Reality XR Plugin.
Can you describe the way of accessing the native SpatialCoordinateSystem using OpenXR?

There are some issues which describe how to access a SpatialCoordinateSystem as a Unity/C# Object (e.g. in the Unity forum or in this repository) with OpenXR, but the solutions do not describe how to get the native pointer (IntPtr) (Allocating a GCHandle from the C# object obviously can not be used as a Windows::Perception::Spatial::ISpatialCoordinateSystem^ in c++).

Is there a way on accessing the native pointer of the origin SpatialCoordinateSystem ?

In c++ we are currently casting the pointer via:

reinterpret_cast<Windows::Perception::Spatial::ISpatialCoordinateSystem ^>(unitySpatialCoordinateSystemIntPtr);

and use it for getting the transform to a specific frame:

unitySpatialCoordinateSystem->TryGetTransformTo(frameCoordinateSystem);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions