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.

Move, rotate and resize object like in the Holograms app

I am just starting to work with Unity and Hololens and I am trying to create a simple app similar to the included hologram application.

  1. I want to make it easy for the user to move an object and place it in the real environment (on a table for instance). so they can walk around it and view all angles.
  2. If possible i would also like to allow the user to resize and rotate the object.

The Holographic Academy walks through rotating an object which I imagine can be extrapolated to resize relatively easily. The problem with the Academy is that they appear to be using a different version of the Holotoolkit so the examples don't translate.

While I have a lot of experience with C# programming, I feel like I am playing a different sport and even though I can follow the tutorials I am having trouble intuiting how everything links together in Unity. This means I am having a hard time extending the specific examples into other topics.

I was hoping someone could recommend:

  • if the source to the holograms app was available then that would really be the easiest thing, but it doesn't appear to be the case.
  • There appears to be a lot of value in the unity asset store. Are there any store items that will assist with the task?
  • If there are other tutorials or samples i could take a look at that are specific to my case or relatively condensed general documentation.

Sorry for such a general question but i am feeling like a fish out of water.

TIA,
Logan

Answers

  • This is exactly what i was looking for.
    I have been able to use it to do a lot of what i needed, i do have a couple of code location questions though:
    1) Where is the logic that handles the buttons? What if i wanted to add or remove a button?
    2) Where is the logic that handles the actual manipulation? I ultimately want to also allow a user to use an xbox controller.
    3) I want to allow the user to turn off the selection (box) without selecting a different item. I am assuming that would be in the box code, but i haven't found it yet. Can i just tie to the click event and loop through all objects and turn off selection?

    Thanks again this really pointed me in the right direction.

  • RailboyRailboy
    edited June 2017

    @clmckinley said:
    1) Where is the logic that handles the buttons? What if i wanted to add or remove a button?

    Each handle is a gameobject with a BoundingBoxHandle component. BoundingBoxHandle extends our Button class, which automatically pick up taps, manipulation, focus events etc.

    BoundingBoxManipulate extends the InteractionReceiver class, which can process events from multiple objects. You can see the handle objects in the prefab's 'Interactibles' array - events from objects in that array are automatically picked up by InteractionReceiver 's OnManipulationStarted / OnManipulationUpdated / OnManipulationFinished / etc. functions. Those functions are where we determine which handle was targeted and initiate manipulation.

    2) Where is the logic that handles the actual manipulation? I ultimately want to also allow a user to use an xbox controller.

    You'll find that in the UpdateUserManipulation function.

    One option for gamepad support would be to override InteractionReceiver's OnTapped function, which is triggered by the X button. You could initiate manipulation there, then use InputSources.Instance.unityGamepad instead of the player's hand position.

    3) I want to allow the user to turn off the selection (box) without selecting a different item. I am assuming that would be in the box code, but i haven't found it yet. Can i just tie to the click event and loop through all objects and turn off selection?

    BoundingBoxManipulate has no built-in selection behavior. That's actually in a separate script called BoundingBoxTarget. It just sets the bounding box's target to itself when it gets a Tapped event. You could write a script that cycles through a list of objects instead.

    If you want a clearer idea of how the interaction system works check out the InteractableObject_Examples scene. The BoundingBoxManipulate prefab is just a bunch of these simpler behaviors stapled together:
    https://github.com/Microsoft/MRDesignLabs_Unity/blob/master/DesignLabs_Unity_Examples/Assets/MRDL_ControlsExample/Scenes/InteractableObject_Examples.unity

  • @clmckinley said:
    1) Where is the logic that handles the buttons? What if i wanted to add or remove a button?

    If you dig through the prefab you'll see that handles are separate objects w/ BoundingBoxHandle components attached. BoundingBoxHandle extends our Button class, which automatically picks up taps, manipulation, focus events, etc.

    The BoundingBoxManipulate class extends InteractionReceiver, which is used to gather events from multiple sources. If you look in the prefab's 'Interactibles' array you'll see all the handle objects in there - events from those object are forwarded to InteractionReceiver's OnManipulateStarted / OnManipulateUpdated / OnManipulateFinished functions, which we use to initiate manipulation.

    BoundingBoxHandle / BoundingBoxManipulate are made to emulate the shell so if you want to change the button setup I'd recommend starting fresh and extending the BoundingBox base class. This class has no built-in manipulation technique so you could use whatever handle scheme you want.

    2) Where is the logic that handles the actual manipulation? I ultimately want to also allow a user to use an xbox controller.

    You'll find that in UpdateUserManipulation.

    For gamepad input, one option would be to override InteractionReceiver's OnTapped function, which responds to X button input. You could initiate manipulation there, then use InputSources.Instance.unityGamepad for input instead of the user's hands.

    3) I want to allow the user to turn off the selection (box) without selecting a different item. I am assuming that would be in the box code, but i haven't found it yet. Can i just tie to the click event and loop through all objects and turn off selection?

    BoundingBoxManipulate has no built-in selection behavior. That's actually in a separate script called BoundingBoxTarget, which just sets the bounding box's Target object to itself when tapped. You could write a new script that selects the next object in an array instead.

    If you want to get a firmer grasp on the interaction system definitely check out the InteractableObject_Examples scene. The bounding box prefab is just a bunch of these simpler behaviors stapled together:
    https://github.com/Microsoft/MRDesignLabs_Unity/blob/master/DesignLabs_Unity_Examples/Assets/MRDL_ControlsExample/Scenes/InteractableObject_Examples.unity

    Thanks again this really pointed me in the right direction.

    No problem! Let us know if you have any suggestions or feature requests.

  • Hi, I have another very beginner question!

    I am having some trouble making use of these prefabs in my own project. If I import them individually, the scripts don't compile. If I open the MR Design Lab project and export it as a custom package then import it, says "The associated script cannot be loaded"

    Any advice on how I can make use of these resources is greatly appreciated :smile:

  • Hi @jayhersk, please copy the folder Assets\MRDesignLab (which includes HUX folder) into your project. This bounding box prefab and scripts uses the components in HUX folder.

  • If you dig through the prefab you'll see that handles are separate objects w/ BoundingBoxHandle components attached. BoundingBoxHandle extends our Button class, which automatically picks up taps, manipulation, focus events, etc.

    The BoundingBoxManipulate class extends InteractionReceiver, which is used to gather events from multiple sources. If you look in the prefab's 'Interactibles' array you'll see all the handle objects in there - events from those object are forwarded to InteractionReceiver's OnManipulateStarted / OnManipulateUpdated / OnManipulateFinished functions, which we use to initiate manipulation.

    @Railboy this is helpful, thank you.

    To be honest though, i still don't completely see where that ties into the prefab, but i can get it to hit a breakpoint so i am able to work my way through it. I am starting to understand more about how the system is tied together.

    That said, the next two major things that i am trying to get to work are:
    1) spatial orientation - Basically i want to have the object stop dragging when i hit a surface (like a table or the floor). I have been working with this some today, but again i am running into some problems with many of the samples using different (unspecified) versions of the holotoolkit so the sample doesn't work as written with the latest. Every time I follow the steps i see the mapping, but when i turn gravity on my object seems to just fall right through the floor.
    a) which version of the toolkit do you have included and is there an easy way to tell the version?
    b) do you have any examples or tutorials that might help?

    2) the next step would be to share the environment with other hololens systems. This seems well documented, but i have run into the problem of documentation not matching the toolkit on every step.

    this is what my project looks like: http://imgur.com/a/9b2Sh

    Thanks again, i would be much further from my goal and much more frustrated if it weren't for your help.

    • Logan
  • @cre8ivepark When I copy that folder into my project I still get the message "The associated script cannot be loaded. Please fix any compile errors and assign a valid script."

    This happens even when I try to copy it into a fresh project

  • @jayhersk said:
    @cre8ivepark When I copy that folder into my project I still get the message "The associated script cannot be loaded. Please fix any compile errors and assign a valid script."

    This happens even when I try to copy it into a fresh project

    Did you remember to run these commands?

    • "git submodule init"
    • "git submodule update"
  • jayherskjayhersk
    edited July 2017

    @nbckr My project is not a git repository so I can't run these commands... still not sure where to go from here. My current set up is just a unity project, then I downloaded the MRDL source code zip file, unpacked it, and tried to copy the specified folder into my project. If I am missing a step please let me know.

  • I can't find the code on how to do this. When I open the examples project I am getting script errors.

  • DamienSDamienS
    edited January 2018

    Hi, my colleague advised me to use BoundingBoxTarget and AppBar but I can't find it in the last version of MRToolkit.
    Is there something with a different name that does the same work, or a version of MRDL that still works in the last version of Unity ?
    (he was having trouble with absence of collision on his buttons)

    EDIT: Ok, I've seen the message on the MRDL Git page for future migration so I know it will come soon in MRToolkit.
    But still can't find old BoundingBox in MRDL.

  • Hi, you can try my full tutorial on how to move, resize or rotate objects in your HoloLens apps using MR-Toolkit-Unity 2017.2 version (as latest as it gets) https://codeholo.com/2018/05/06/move-resize-and-rotate-objects-in-your-hololens-apps/

Sign In or Register to comment.