Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

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.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. 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. And always feel free to hit us up on Twitter @MxdRealityDev.

Tap and Drag to Place

I'm looking for a way to implement a "Tap and Drag to place".
It's like TapToPlace but instead of using gaze, i want to use the movements of my hand.
now, I was watching the 211 academy and somehow there is a way in there.
I saw that they used the voice input, then got to PerformManipulationStart then PerformManipulationUpdate where they place the astronaut according to the position of the hand.
Can you guys tell me if I can use that with a simple OnSelect and if it can be used with the spatial mapping to place objects.

Answers

  • Hi Angelica,

    Yep. That'll work. You'll want to add a GestureManipulation script to the objects you want to move and only enable an object's GM when it has focus and gets tapped. Then disable the GestureManipulator again on the second tap. The GM's update method will look something like this:

        void Update()
        {
            if (hasFocus && Manipulating)
            {
                Vector3 localHandPosition = Camera.main.transform.InverseTransformPoint(GestureManager.Instance.ManipulationHandPosition);
                Vector3 initialHandToCurrentHand = localHandPosition - initialHandPosition;
                Vector3 scaledLocalHandPositionDelta = Vector3.Scale(initialHandToCurrentHand, handPositionScale);
                Vector3 localObjectPosition = initialObjectPosition + scaledLocalHandPositionDelta;
                Vector3 worldObjectPosition = Camera.main.transform.TransformPoint(localObjectPosition);
                if (targetInterpolator != null)
                {
                    targetInterpolator.SetTargetPosition(worldObjectPosition);
                }
                else
                {
                    transform.position = worldObjectPosition;
                }
            }
        }
    

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • edited November 2016

    @james_ashley said:
    Hi Angelica,

    Yep. That'll work. You'll want to add a GestureManipulation script to the objects you want to move and only enable an object's GM when it has focus and gets tapped. Then disable the GestureManipulator again on the second tap. The GM's update method will look something like this:

        void Update()
        {
            if (hasFocus && Manipulating)
            {
                Vector3 localHandPosition = Camera.main.transform.InverseTransformPoint(GestureManager.Instance.ManipulationHandPosition);
                Vector3 initialHandToCurrentHand = localHandPosition - initialHandPosition;
                Vector3 scaledLocalHandPositionDelta = Vector3.Scale(initialHandToCurrentHand, handPositionScale);
                Vector3 localObjectPosition = initialObjectPosition + scaledLocalHandPositionDelta;
                Vector3 worldObjectPosition = Camera.main.transform.TransformPoint(localObjectPosition);
                if (targetInterpolator != null)
                {
                    targetInterpolator.SetTargetPosition(worldObjectPosition);
                }
                else
                {
                    transform.position = worldObjectPosition;
                }
            }
        }
    

    can I ask you to be more specific?

    in my mind, i write the Gesture manipulation(i saw that there is one,very similar to your suggestion, from the HoloToolKit) then have a Cube manipulator script where i write in the OnSelect method the piece of code from the 211 tutorial(the one the moves the astronaut)

    I hope you can provide a little step by step since i'm making my project from zero and everything seems to be confusing. :smile:

  • edited November 2016

    @james_ashley. i was able to make a cube move. the truth i only replaced the astroman with a cube. somehow the moving works!
    i now only have to add a spatial mapping and solve the range of movement. as for now, the object moves slower than the hand itself and it if left behind. annoying.
    i hope I can figure out how to make things work. :)
    evry suggestion is well accepted.

    Vector3 moveVector = Vector3.zero;

            // 4.a: Calculate the moveVector as position - manipulationPreviousPosition.
            moveVector = position - manipulationPreviousPosition;
    
            // 4.a: Update the manipulationPreviousPosition with the current position.
            manipulationPreviousPosition = position;
    
            // 4.a: Increment this transform's position by the moveVector.
            transform.position += moveVector; 
    

    this the piece of code used tomove the object.
    this is very slow, so I was wondering if I can multiply moveVector to a sort of movement sensibility to make movement faster.
    i know that this piece is executed frame frame.

  • @angelicaHolo,

    If you take a look at the GestureManipulator behaviour that comes with the HoloToolkit, there's a config setting at the top to set the sensitivity. You can up these values to make the movements more sensitive:

        [Tooltip("How much to scale each axis of hand movement (camera relative) when manipulating the object")]
        public Vector3 handPositionScale = new Vector3(2.0f, 2.0f, 4.0f);  // Default tuning values, expected to be modified per application
    

    James

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

Sign In or Register to comment.