Replies: 2 comments 2 replies
-
According to this comment one can access the "sceneCoordinateSystem" via: using namespace Microsoft.MixedReality.OpenXR;
SpatialCoordinateSystem origin = PerceptionInterop.GetSceneCoordinateSystem(UnityEngine.Pose.identity) as SpatialCoordinateSystem; But this does not answer the question on how to get the underlying native pointer. I tried several approaches which all resulted in some error: The following errors occur: var handle = GCHandle.Alloc(origin , GCHandleType.Pinned); // <-- Error
IntPtr coordinateSystemNative = (IntPtr)(handle);
var handle = GCHandle.Alloc(origin);
IntPtr coordinateSystemNative = (IntPtr)(handle);
// Error in assigning the variable in c++
var handle = GCHandle.Alloc(origin);
IntPtr coordinateSystemNative = handle.AddrOfPinnedObject(); // <-- Error
IntPtr coordinateSystemNative = Marshal.GetIUnknownForObject(origin);
// Error in using the variable in c++
// sceneCoordinateSystem->TryGetTransformTo(frameCoordinateSystem);
Can you tell me, how is the correct way to get this |
Beta Was this translation helpful? Give feedback.
-
The result from You'll want to use |
Beta Was this translation helpful? Give feedback.
-
Before Unity 2019.3, one has been able to access the native pointer to the world
SpatialCoordinateSystem
viaUnityEngine.XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr()
.Switching to Unity 2019 one is able to access the same pointer via
UnityEngine.XR.WindowsMR.WindowsMREnvironment.OriginSpatialCoordinateSystem
using theWindows 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 aGCHandle
from the C# object obviously can not be used as aWindows::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);
Beta Was this translation helpful? Give feedback.
All reactions