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.
Tutorial 211
I am learning tutorial 211. I am confused about how to implement "manipulation" exactly. In GestureAction.cs, there are two functions: PerformManipulationStart and PerformManipulationUpdate. In each of these two, the input is Vector3 position, and the input is passed from functions in GestureManager.cs.
However I do not understand what do these two position stand for relatively? I mean, as to control the gameobject moving following hands, we should use initial position and update it by new position where hands move to.
Best Answer
-
Optionsahillier mod
Hi @RosieLiu,
The logic for subscribing and handling Manipulation events is provided in GestureManager.cs. We don't have you do this part in the tutorial, because registering for and handling these events is very similar to what you already did for Navigation. These event handlers are all located in GestureManager.cs, and worth taking a look at to help understand how to implement Manipulation in your own application.The outcome that you describe for Manipulation is correct, and this is what you'll implement in GestureAction.cs:
to control the gameobject moving following hands, we should use initial position and update it by new position where hands move to
In PerformManipulationStart, you store the position of the hand when the manipulation gesture is first detected. Hand position is provided by ManipulationRecognizer_ManipulationStartedEvent in GestureManager.cs.
void PerformManipulationStart(Vector3 position) { manipulationPreviousPosition = position; }
In PerformManipulationUpdate, you calculate the movement vector (which determines how far, and in what direction you will need to move the hologram) by using the current hand position (provided by ManipulationRecognizer_ManipulationUpdatedEvent in GestureManager.cs) and then subtract the previous position saved off by the PerformManipulationStart method. Multiple Updates will be called while the manipulation gesture is being performed, so you'll overwrite the previous position with the current position for recalculating the movement vector during the next update.
void PerformManipulationUpdate(Vector3 position) { if (GestureManager.Instance.IsManipulating) { Vector3 moveVector = Vector3.zero; // Calculate the moveVector moveVector = position - manipulationPreviousPosition; // Update manipulationPreviousPosition with current position. manipulationPreviousPosition = position; // Move the hologram. transform.position += moveVector; } }
To the Hololens, Manipulation and Navigation gestures look identical. So in order to trigger Manipulation, we use a keyword 'Move Astronaut', which will disable Navigation and enable Manipulation. This logic has been provided for you in AstronautManager.cs (registers the keyword) and GestureManager.cs (transitions between Navigation and Manipulation). As soon as a gesture completes, HandsManager.cs will reset GestureManager, so that it will listen for Navigation events again (so you'll have to say the keyword every time that you want to use Manipulation). If you write an application that uses both Manipulation and Navigation, then you will need to provide similar functionality for switching between the two modes, because they can't be used simultaneously.
I hope this explanation helps. If you need more clarification, don't hesitate to ask!
Thanks,
~Angela5
Answers
Hi @RosieLiu,
The logic for subscribing and handling Manipulation events is provided in GestureManager.cs. We don't have you do this part in the tutorial, because registering for and handling these events is very similar to what you already did for Navigation. These event handlers are all located in GestureManager.cs, and worth taking a look at to help understand how to implement Manipulation in your own application.
The outcome that you describe for Manipulation is correct, and this is what you'll implement in GestureAction.cs:
In PerformManipulationStart, you store the position of the hand when the manipulation gesture is first detected. Hand position is provided by ManipulationRecognizer_ManipulationStartedEvent in GestureManager.cs.
In PerformManipulationUpdate, you calculate the movement vector (which determines how far, and in what direction you will need to move the hologram) by using the current hand position (provided by ManipulationRecognizer_ManipulationUpdatedEvent in GestureManager.cs) and then subtract the previous position saved off by the PerformManipulationStart method. Multiple Updates will be called while the manipulation gesture is being performed, so you'll overwrite the previous position with the current position for recalculating the movement vector during the next update.
To the Hololens, Manipulation and Navigation gestures look identical. So in order to trigger Manipulation, we use a keyword 'Move Astronaut', which will disable Navigation and enable Manipulation. This logic has been provided for you in AstronautManager.cs (registers the keyword) and GestureManager.cs (transitions between Navigation and Manipulation). As soon as a gesture completes, HandsManager.cs will reset GestureManager, so that it will listen for Navigation events again (so you'll have to say the keyword every time that you want to use Manipulation). If you write an application that uses both Manipulation and Navigation, then you will need to provide similar functionality for switching between the two modes, because they can't be used simultaneously.
I hope this explanation helps. If you need more clarification, don't hesitate to ask!
Thanks,
~Angela
Thanks! It helps!
@ahillier
what if i want to use manipulation without the voice input?
i'm using Gesture and hands manager from the HTK. they are quite different from the managers from the 211 lesson.
i have
private void ManipulationRecognizer_ManipulationStartedEvent(InteractionSourceKind source, Vector3 cumulativeDelta, Ray headRay)
in my Gesture Manager. in this method i verify Gesture.Manager.Instance!=null then i call the PerformModify method where I put the vector calculations from the 211 lesson. but nothing seem to happen and I can't figure out why.
I was wondering if you can help me with this.