Hello everyone.

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.
Options

Move, Scale and Rotate Object

Good evening,

i found out how to move and rotate my object. Next step is to scale them. The HoloToolKit have an example Code for scaling (ScaleObjectMessageReceiver.cs) but it doesn't works. Can someone tell me please step by step what schould i have to do. I am an beginner and appreciate your help.

Thanks a lot
Memo

Best Answer

  • Options
    HoloSheepHoloSheep mod
    Answer ✓

    @Memo

    Assuming you are saying that you want to provide an interface to the user so that they can choose between moving, rotating and scaling with the "navigation gesture"...

    You could create and set a custom NavigationMode variable (move, rotate, scale) with a voice command and/or you could also create UI that the user could air tap to set the mode.

    For UI the three common approaches that come to mind are either display separate element

    • 3D TextMesh
    • Unity UI
    • or use some 3D geometry (aka model)
      and by using a box collider around any of the above you should be able to capture the AirTap gesture when the user air taps on the UI element and then execute code set your mode variable there.

    Regardless of which method or combination of methods you provide the user to set the mode variable, you would include conditional logic inside your GestureAction method to check the NavigationMode variable and based on its value then execute the correct logic to either move, rotate or scale the target game object.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

Answers

  • Options

    @Memo
    Scaling can be done with routines something like the following:

      public void OnBigger()
        {
            this.gameObject.transform.localScale = new Vector3(this.gameObject.transform.localScale.x * 2, this.gameObject.transform.localScale.y * 2, this.gameObject.transform.localScale.z * 2);
        }
    
        public void OnSmaller()
        {
            this.gameObject.transform.localScale = new Vector3(this.gameObject.transform.localScale.x / 2, this.gameObject.transform.localScale.y / 2, this.gameObject.transform.localScale.z / 2);
        }
    

    These routines will double or half your gameobject's size.

    You typically would include them in some sort of controller script that you attach to your gameobject (or its parent wrapper depending on your object hierarchy).

    If you make them public like the ones above you can then also easily wire them up to the keyword recognizer in your app so that a voice command of "Bigger" or "Smaller" could trigger the scaling.

    HTH.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • Options

    @HoloSheep thank's a lot for the code. I am using the similar code from the HoloLens Tutorial 211 and added some code for rotation in GestureManager and GestureAction (see below). Do I need to add some code for scaling in GestureAction and **GestureManager **too?

    GestureManger:

    NavigationRecognizer.SetRecognizableGestures(
    GestureSettings.Tap |
    GestureSettings.NavigationX |
    GestureSettings.NavigationY |
    GestureSettings.NavigationZ);

    And GestureAction:

    private void PerformRotation()
    {
    if (GestureManager.Instance.IsNavigating)
    {

            float rotationFactor_Y = GestureManager.Instance.NavigationPosition.x * RotationSensitivity;
    
            float rotationFactor_X = GestureManager.Instance.NavigationPosition.y * RotationSensitivity;
    
            float rotationFactor_Z = GestureManager.Instance.NavigationPosition.z * RotationSensitivity;
    
            transform.Rotate(new Vector3(rotationFactor_X, -1 * rotationFactor_Y, rotationFactor_Z));
        }
    }
    
  • Options

    @Memo it all depends on how you want the scaling interaction to work.

    If your plan is to scale with gestures, do you also want your model to rotate and scale at the same time with the same gesture or do you want to create conditional logic to differentiate between the modes for rotating vs scaling.

    You should be able to replace your is navigating logic above with very similar scaling logic if that is what you want.

    Or alternatively you could scale with a different interaction like voice... it is up to you.

    If you plan to use the navigation gesture for multiple types of interactions, you will likely want to create some sort of interface or command to set the interaction mode (scale, rotate, move, etc...) and take the appropriate action in your gesture action based on the mode that you are in.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • Options

    Hi @HoloSheep i finally found out with your help how to scale objects with the voice command.

    I want to achieve that I have an interface where you can choose between moving, rotating and scaling. How should I proceed and what can you recommend me. Appreciate your help

  • Options
    HoloSheepHoloSheep mod
    Answer ✓

    @Memo

    Assuming you are saying that you want to provide an interface to the user so that they can choose between moving, rotating and scaling with the "navigation gesture"...

    You could create and set a custom NavigationMode variable (move, rotate, scale) with a voice command and/or you could also create UI that the user could air tap to set the mode.

    For UI the three common approaches that come to mind are either display separate element

    • 3D TextMesh
    • Unity UI
    • or use some 3D geometry (aka model)
      and by using a box collider around any of the above you should be able to capture the AirTap gesture when the user air taps on the UI element and then execute code set your mode variable there.

    Regardless of which method or combination of methods you provide the user to set the mode variable, you would include conditional logic inside your GestureAction method to check the NavigationMode variable and based on its value then execute the correct logic to either move, rotate or scale the target game object.

    Windows Holographic User Group Redmond

    WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
    WinHUGR YouTube Channel -- live streamed meetings

  • Options

    hi @HoloSheep

    I forgot to thank you.
    Greetings from Germany :smile:

  • Options

    @Memo @HoloSheep Hello, I'm very new in Unity and Hololens. Now I can move my hologram(an assembly) with "Hand draggable", but how to rotate the hologram with holotoolkit. I finished all the acedemy tutorial, but there're no such scripts called"gesture action""gesture manager",etc in holotoolkit. So what scripts should I use to rotate and expand my hologram? Thanks a lot.

  • Options

    Hi @Memo and @HoloSheep you guys have a good knowledge about this topic. I am also new with this stuff and i could kindly need some support. I am studying mechanical engineering and my thesis deals with the hololens. It's a little bit difficult to handle with some topic you nearly never had til right now. So i am asking you guys if you could support me a little bit. I would like to move, scale and rotate objects with the help of gesture, gaze and voice control. i appreciate any help and wish you guys good luck with your development.

    hope to hear from you soon

    thanks

  • Options

    With the new HoloToolkit you probably would like to trigger your rotation code by using the interface INavigationHandler and implement OnNavigationUpdated(NavigationEventData eventData) but exactly how I'm not sure. Anyone have any suggestions?

  • Options

    @Harald , Hi

    Did you find a way to rotate a gameobject using INavigationHandler and OnNavigationUpdated. I'm looking for a similar way to rotate a gameobject

    Thanks,
    Pranav

Sign In or Register to comment.