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.
Position Independent Object Placement
Hey all,
this is kind of a follow-up question to what has been discussed here:
https://forums.hololens.com/discussion/1162/holograms-230-chapter-1-no-room-mesh-displayed
There, user ahilier says "As David mentions above, the SRMesh should only load while in the Unity Editor. [...] The coordinates (0,0,0) is the location of the camera (HoloLens) when the application first launches. This will be considered the center of the holographic world."
I understand that. But then, how can I place 3D Objects in my scene independent of the position the user is in when he/she launches the app.
For example, say I want to display an object on some table in my room. I want this object to be at the exact same position (on the table) no matter where i currently am in the room when I launch the app.
So basically, I want to do the same thing as Microsofts "Holograms" app does on the "main menu" screen of the Hololens.
Can anyone help?
Thanks, Kev
Best Answer
-
Optionsahillier mod
Hi @kvnmlr,
If you are having the user place holograms (like in the 'Holograms' app), then you can remember their location using spatial anchors (also known as 'World Anchors' in Unity). When the user loads your application a second time, their holograms will appear wherever they set them in the earlier session.@Patrick recently added a WorldAnchorManager script to HoloToolkit-Unity to help with saving/loading spatial anchors. You can see how to use this script by looking at the TapToPlace script and the test scene of the same name in the SpatialMapping folder.
If you're trying to place holograms without any user input, then I would suggest looking at the SpatialUnderstanding feature in HoloToolkit. This component will help analyze your space and find where placeable positions exist in the room.
5
Answers
Hi @kvnmlr,
If you are having the user place holograms (like in the 'Holograms' app), then you can remember their location using spatial anchors (also known as 'World Anchors' in Unity). When the user loads your application a second time, their holograms will appear wherever they set them in the earlier session.
@Patrick recently added a WorldAnchorManager script to HoloToolkit-Unity to help with saving/loading spatial anchors. You can see how to use this script by looking at the TapToPlace script and the test scene of the same name in the SpatialMapping folder.
If you're trying to place holograms without any user input, then I would suggest looking at the SpatialUnderstanding feature in HoloToolkit. This component will help analyze your space and find where placeable positions exist in the room.
I tried the script above but for some reason, WorldAnchorStore.GetAsync is not calling the callback function.
WorldAnchorManager.cs attached to an active game object:
Debug says:
awake
Okay problem is solved, the GetAsync callback is not called in the unity editor. I can now save and reload at runtime instantiated GOs at their correct position. Thanks for the help.
Great answers!
What i am trying to do, without any luck so far, is to have multiple objects in a scene and TapToPlace each object at a position in the room. My problem is that, owing to the WorldAnchor (from HoloToolkit) that i attach to each object, when i start the app all objects appear at (0, 0, 0). So i get around 20 objects appearing one on top of the other...
Is there a way to add persistence to my objects and have them appearing at separate (predefined) positions when i start the app?
I found a solution for anyone having the same problem...
For every object that has the TapToPlace script attached, I went to the Hierarchy/TapToPlace component and under the SavedAnchorFriendlyName variable I typed the name of the game object (any unique name will also work I guess).