-
OverviewThis documentation states that MRTK provides already marshalled types for getting the With Windows XRSDK, I obtained the origin
But with the new OpenXR SDK, this is not working anymore. I tried to access the
but this throws an exception. Expected behaviorThe underlying SpatialCoordinateSystem can be accessed like
Actual behavior
Unity editor versionUnity 2020.3.13f1 Mixed Reality Toolkit release versionMRTK 2.7.2 |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 1 reply
-
If you're looking to locate a second spatial coordinate system relative to it, you should be able to use the Mixed Reality OpenXR Plugin's You'll need the spatial graph ID for the second object, but depending on what you're doing that should be accessible. |
Beta Was this translation helpful? Give feedback.
-
Yes, I use the After playing around a bit, I managed to get a
However, I could not confirm yet that |
Beta Was this translation helpful? Give feedback.
-
Yeah, when running on OpenXR, I'm not sure there's a guarantee that these types will still be valid. OpenXR uses different types for locatability, which I wrote about at #10082 (comment).
|
Beta Was this translation helpful? Give feedback.
-
If you are referring to the properties described here, unfortunately, no. For me, the
which throws an ArgumentOutOfRangeException. |
Beta Was this translation helpful? Give feedback.
-
Okay, I have a better update for you! I recently found out that you can access the root using Microsoft.MixedReality.OpenXR;
using Windows.Perception.Spatial;
SpatialCoordinateSystem origin = PerceptionInterop.GetSceneCoordinateSystem(UnityEngine.Pose.identity) as SpatialCoordinateSystem; The resulting Windows.Perception.Spatial.SpatialCoordinateSystem object is located at the given pose in the current Unity scene. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot @keveleigh, this is exactly what I was looking for! Just tested it and it works great for my applicaiton. Just for completeness, meanwhile, I came up with this, which also seems to work: SpatialLocator locator = SpatialGraphInteropPreview.CreateLocatorForNode(sensorGuid)
Scene scene = Task.Run(GetSceneAsync).GetAwaiter().GetResult();
SpatialCoordinateSystem sceneOrigin =SpatialGraphInteropPreview.CreateCoordinateSystemForNode(scene.OriginSpatialGraphNodeId);
SpatialGraphNode node = SpatialGraphNode.FromStaticNodeId(scene.OriginSpatialGraphNodeId);
if (node.TryLocate(FrameTime.OnUpdate, out Pose pose))
{
sceneToWorldMatrix = Matrix4x4.TRS(pose.position, pose.rotation, Vector3.one);
}
else
{
Debug.WriteLine("Could not obtain the scene to world matrix.");
} And then use the |
Beta Was this translation helpful? Give feedback.
-
Perfect, thank you for following up! I'm going to close this issue down now as it seems we have a solution. Please reopen if I'm mistaken. Thanks! |
Beta Was this translation helpful? Give feedback.
Okay, I have a better update for you! I recently found out that you can access the root
SpatialCoordinateSystem
via a helper function in the Mixed Reality OpenXR Plugin package:The resulting Windows.Perception.Spatial.SpatialCoordinateSystem object is located at the given pose in the current Unity scene.