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.
Shared Holographic Experience, how to have smooth manipulation of anchored objects?
I am working on a project where I need at least two users to see the same object anchored in space. I have this working perfectly fine thanks to the HoloAcademy 240 tutorial.
I now want one user to perform a manipulation on the object (rotation, moving the object, etc.), and have that same manipulation happen in as close to real time as possible for the second user. Note that I still want that anchor in place after the manipulation is finished.
Right now, I do this by destroying the anchor and re-adding it right after the manipulation every frame. This is a code snippet showing what I mean:
void Update { if(ImportExportAnchorManager.Instance.AnchorEstablished) { DestroyImmediate(gameObject.GetComponent<WorldAnchor>()); RotateHologram() //rotate the shared hologram for that frame WorldAnchor anchor = gameObject.AddComponent<WorldAnchor>(); CustomMessages.Instance.SendHologramTransform(gameObject.transform.localRotation); } }
When the second hololens receives this, this is what runs:
void OnHologramTransform(NetworkInMessage msg) { //destroy the anchor again to make manipulations DestroyImmediate(gameObject.GetComponent<WorldAnchor>()); // we read the user id but we don't use it here. msg.ReadInt64(); Quaternion hologramRotation = CustomMessages.Instance.ReadQuaternion(msg); gameObject.transform.localRotation = hologramRotation; //re add after all manipulations done WorldAnchor anchor = gameObject.AddComponent<WorldAnchor>(); }
Again, this works but becomes rather choppy on the second hololens.
Is there a more elegant and smooth implementation than what I am currently doing?
Best Answer
-
OptionsPatrick mod
pessimish, you should watch task manager (or better yet resource monitor) to see how much network traffic the sharing service is generating. It shouldn't be very much for sending a rotation every frame.
And if you are looking for smoother rotations, you might follow DN's advice and try to do some prediction in your code. When a HoloLens gets several rotation transforms in a row, you can calculate the change in rotations and assume the change in rotation will continue in the update function for the object. When rotations stop arriving, you can snap to the last rotation. The end result is you will likely overshoot a little bit, but the overall experience should be better. It will be critical to keep track of the time between rotations from the external HoloLens and create a rotation per second metric, so in the update loop you can continue to rotate by the same speed based on time between update loops.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.(Daddy, what does 'now formatting drive C:' mean?)
5
Answers
ye instead of assigning the rotation directly on the receving end... why dont you smooth the value.. use th einterpolator class or Mathf.Lerp / Mathf.Smooth etc in an update function or a coroutine.
Healthcare IT professional by day - Indie GameDev for UWP and mobile platforms by night
I realized my mistake after posting it to Projects, so if it's possible to move it to Q&A I will do that.
I tried quaternion.lerp on the receiving end and it still has a lag/choppy feel, that wasn't the issue. It has something to do I feel with the destroying and re adding of the anchor, but I'm not sure what better way there is to do it.
I think you need to try setting a parent object with world anchor and dont destroy that one... just have your model as a child of that and rotate the child.
Healthcare IT professional by day - Indie GameDev for UWP and mobile platforms by night
I like this idea, and I will try that as soon as I get back to work on Tuesday.
That being said, the ImportExportAnchorManager script is attached to the parent object, not the object I am manipulating, so I'm not sure why it isn't working out of the box. Without
DestroyImmediate()
nothing happens.+1 to "Don't attach the world anchor to the object you are manipulating."
Consider how the 'energy hub' is manipulated in Holograms 240. We never add a WorldAnchor to the energy hub, just to the 'Hologram Collection' parent of the Energy Hub.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)
Thanks all for your help. I figured out what my problem was. The anchor was fine the way it was (it was already parented), but both hololens were trying to send messages to each other with their transform. This caused the rotation to be very very choppy, almost as if the transform was fighting with a direction to rotate.
The rotation is smoother than it was, but it is still slower than the hololens controlling the manipulation.
pessimish, you should watch task manager (or better yet resource monitor) to see how much network traffic the sharing service is generating. It shouldn't be very much for sending a rotation every frame.
And if you are looking for smoother rotations, you might follow DN's advice and try to do some prediction in your code. When a HoloLens gets several rotation transforms in a row, you can calculate the change in rotations and assume the change in rotation will continue in the update function for the object. When rotations stop arriving, you can snap to the last rotation. The end result is you will likely overshoot a little bit, but the overall experience should be better. It will be critical to keep track of the time between rotations from the external HoloLens and create a rotation per second metric, so in the update loop you can continue to rotate by the same speed based on time between update loops.
===
This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.
(Daddy, what does 'now formatting drive C:' mean?)