The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Spatial Understanding Data
I'm familiar with how to locate different objects using the spatial understanding app from the holotoolkit, but I'm a bit confused on how to make use of that data. Say I wanted to place an object on a wall in the room, how could I go about doing that?
Thanks
Best Answers
-
Optionsstepan_stulov ✭✭✭
There are these major steps involved into this:
In order to pin something onto the wall you need to know where that wall is. This is done by finding an intersection of your camera's forward ray (gaze forward) with a collider of the spatial mapping provided for you by the SpatialMappingCollider component. You typically find the intersection via raycasting. See Physiscs.Raycast() method.
Now that you have the point at which you wish your object to be you need to first place it there manually by simply assigning the object's location to the point from the previous step. And then delegate keeping the object stable to the spatial mapping topology to HoloLens's API. This is done simply by adding a WorldAnchor component to your game object. Note that manual changing of object's location and it having a world anchor are mutually exclusive modes.
Additionally you can preserver those world anchors between application relaunches by using WorldAnchorStore or even exchange blobs of anchors via WorldAnchorTransferBatch.
Hope this helps.
Building the future of holographic navigation. We're hiring.
5 -
Optionsstepan_stulov ✭✭✭
@themightyoo I have adjusted my answer slightly. To have an object stay pinned onto the wall you need (2) and to ALSO have that preserved between application re-launches you need (3).
PS: Please note that when redeploying the app the WorldAnchorStore is unfortunately erased. To solve this migration problem you may utilise WorldAnchorTransferBatch and write its bytes into a files instead. I haven't tested this solution though.
Building the future of holographic navigation. We're hiring.
5
Answers
There are these major steps involved into this:
In order to pin something onto the wall you need to know where that wall is. This is done by finding an intersection of your camera's forward ray (gaze forward) with a collider of the spatial mapping provided for you by the SpatialMappingCollider component. You typically find the intersection via raycasting. See Physiscs.Raycast() method.
Now that you have the point at which you wish your object to be you need to first place it there manually by simply assigning the object's location to the point from the previous step. And then delegate keeping the object stable to the spatial mapping topology to HoloLens's API. This is done simply by adding a WorldAnchor component to your game object. Note that manual changing of object's location and it having a world anchor are mutually exclusive modes.
Additionally you can preserver those world anchors between application relaunches by using WorldAnchorStore or even exchange blobs of anchors via WorldAnchorTransferBatch.
Hope this helps.
Building the future of holographic navigation. We're hiring.
@stepan_stulov So just to clarify, isn't something like this site specific? Especially when I'm moving to a different room, what if i always want two rectangles to be anchored on the walls to my left and right side when the app starts, how do i make sure that when I step into a bigger room that these objects aren't simply floating in space?
@themightyoo I have adjusted my answer slightly. To have an object stay pinned onto the wall you need (2) and to ALSO have that preserved between application re-launches you need (3).
PS: Please note that when redeploying the app the WorldAnchorStore is unfortunately erased. To solve this migration problem you may utilise WorldAnchorTransferBatch and write its bytes into a files instead. I haven't tested this solution though.
Building the future of holographic navigation. We're hiring.