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.

Moving and scaling an object according to hand position.

Hi,
I need some help with my college project. I have a cylinder and need it to act as a coil. For example, if I touched the cylinder's surface it's height will decrease (scaled in the y direction) as if pressing on a coil then when I remove my hand it returns back to its original size.
This is what I reached till now but I still have some problems that I can't solve.

public class Deformation : MonoBehaviour
{

Vector3 tempPos;

private void InteractionManager_SourceUpdated(InteractionSourceUpdatedEventArgs hand)
{
    if (hand.state.source.kind == InteractionSourceKind.Hand)
    {
        Vector3 handPosition;
        hand.state.sourcePose.TryGetPosition(out handPosition);

        float negXRange = transform.position.x - transform.localScale.x;
        float posXRange = transform.position.x + transform.localScale.x;
        float negYRange = transform.position.y - (transform.localScale.y / 2);
        float posYRange = transform.position.y + (transform.localScale.y / 2);
        float negZRange = transform.position.z - transform.localScale.z;
        float posZRange = transform.position.z + transform.localScale.z;

        float handX = handPosition.x;
        float handY = handPosition.y;
        float handZ = handPosition.z;

        if ((negXRange <= handX) && (handX <= posXRange) && (negYRange <= handY) && (handY <= posYRange) && (negZRange <= handZ) && (handZ <= posZRange))
        {
            tempPos.y = handPosition.y;
            transform.localScale = tempPos;
        }
        else
        {
            tempPos.y = 0.3f;
            transform.localScale = tempPos;
        }
    }
}

// Use this for initialization
void Start()
{
    tempPos = transform.localScale;

    InteractionManager.InteractionSourceUpdated += InteractionManager_SourceUpdated;
}  
  1. I attached two scripts to my object (cylinder) the TapToPlace script from the HoloToolKit and the deformation script stated above. The problem is when I deploy to my HoloLens to test, when I place the cylinder first to the needed place then try to deform it after that, it is placed but not deformed. If I tried it the other way around both work. Any ideas why does the deformation script does not work after the TapToPlace one?

  2. The cylinder when viewed by my HoloLens is somehow transparent. I mean that I can see my hand through it. I need it to be more solid.

  3. I wonder if there is something like a delay that I can use because when I use the deformation script stated above the cylinder is scaled to my hand position then scaled back to its default size very fast and appears as if blinking.

  4. At first I place the cylinder on a setup (something as a table for example) then I begin to deform it. When I commented the else part in the deformation script stated above, it was scaled and left stable without returning to the original size. It is scaled symmetrically so its height is decreased from up and down resulting in the base of the cylinder becomes away from the table. I need the base of the cylinder to be always stable and touching the table under it.

    Note: I am using Unity 2017.3.1f1 (64-bit) - HoloToolkit-Unity-2017.2.1.3

    Thank you in advance.

Answers

Sign In or Register to comment.