How to scale a Box with gaze and air-tap

Hi,
today I want create a bounding box like in the normal hologram app from the hololens. On the edges are cubes to scale the holograms. But how can I reconstruct that?

Is there anybody how can explain that to me?

Thanks.

Pad

Basically each controls will change the scale from each of the coordinates of the Transform component of the 3D model.

I understand what you say but how can I scale the object without to change the pivot point. Actually its in the center but when I use a handle on the top so the pivot point has to be on the bottom. That it only grow upwards.

Are you using the manipulation APIs from Gesture Recognizer?

Hi, which methode do you mean? I can not find anything within the Gesture Recognizer.

In GestureRecogtnizer there are a few different things you can try, there is the manipulation events, and also one that might be worth exploring is the navigation on the rails.

You can see example code using GestureRecognizer in the documentation.

Here is a snippet

m_GestureRecognizer = new GestureRecognizer();

m_GestureRecognizer.SetRecognizableGestures(GestureSettings.ManipulationTranslate
| GestureSettings.Tap);
m_GestureRecognizer.ManipulationStartedEvent += M_GestureRecognizer_ManipulationStartedEvent;
m_GestureRecognizer.ManipulationUpdatedEvent += M_GestureRecognizer_ManipulationUpdatedEvent;
m_GestureRecognizer.ManipulationCompletedEvent += M_GestureRecognizer_ManipulationCompletedEvent;
m_GestureRecognizer.ManipulationCanceledEvent += M_GestureRecognizer_ManipulationCanceledEvent;

m_GestureRecognizer.StartCapturingGestures();

GestureRecognizer methods only realise a methode or what you are doing with your hands… but there is nothing to manipulate the size.

The main question is “how to scale the object in one direction” and to link this to the view and hit point of it.

using UnityEngine;
using System.Collections;

public class ScaleQuad : MonoBehaviour
{

public GameObject master; //Empty before the Quad
public GameObject quad; //The Quad I want to scale
Raycast hitInfo;
private Vector3 offsetOld;


void Update()
{
    var headPosition = Camera.main.transform.position;
    var gazeDirection = Camera.main.transform.forward;

    if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
    {
        //Create the offset
        offset = hitInfo.point - master.transform.position;
       
        // To get the new offset between hitpoint and master.transform.position for the new size
        Vector3 diff = offset - offsetOld;

        vFBMaster.transform.position = new Vector3((diff.x + master.transform.position.x), (diff.y + master.transform.position.y), master.transform.position.z);
        quad.transform.localScale = new Vector3((diff.x / 2) + quad.transform.localScale.x, (diff.y / 2) + quad.transform.localScale.y, quad.transform.localScale.z);

        Debug.Log(diff);

        //To save the old offset
        offsetOld = offset;

        Debug.Log("Old Offset = " + offsetOld);
        Debug.Log("new Offset = " + offset);
    }
}
}

Hello,

There is a way to manipulate size, you look at event navigation or manipulation using gesture there is a Vector3 relativePosition or cumulativeDelta in the function. You can use the Vector3 to transform position, local scale, etc… You can use only the x, y, or z coordinates if you desire.

Example:
public class GestureManipulation : MonoBehaviour {

GestureRecognizer m_GestureRecognizer = null;
public GameObject Go;

void Start()
{
m_GestureRecognizer = new GestureRecognizer();

m_GestureRecognizer.SetRecognizableGestures(GestureSettings.ManipulationTranslate
| GestureSettings.Tap);
m_GestureRecognizer.ManipulationStartedEvent += M_GestureRecognizer_ManipulationStartedEvent;
m_GestureRecognizer.ManipulationUpdatedEvent += M_GestureRecognizer_ManipulationUpdatedEvent;
m_GestureRecognizer.ManipulationCompletedEvent += M_GestureRecognizer_ManipulationCompletedEvent;
m_GestureRecognizer.ManipulationCanceledEvent += M_GestureRecognizer_ManipulationCanceledEvent;

m_GestureRecognizer.StartCapturingGestures();
}

private void M_GestureRecognizer_ManipulationCanceledEvent(InteractionSourceKind source, Vector3 cumulativeDelta, Ray headRay)
{
Debug.Log(“Manipulation Canceled”);
}

private void M_GestureRecognizer_ManipulationCompletedEvent(InteractionSourceKind source, Vector3 cumulativeDelta, Ray headRay)
{
Go.transform.localScale = cumulativeDelta;
Debug.Log(“Manipulation Complete”);
}

private void M_GestureRecognizer_ManipulationUpdatedEvent(InteractionSourceKind source, Vector3 cumulativeDelta, Ray headRay)
{
Go.transform.localScale = cumulativeDelta;
Debug.Log(“Manipulation Update”);
}

private void M_GestureRecognizer_ManipulationStartedEvent(InteractionSourceKind source, Vector3 cumulativeDelta, Ray headRay)
{
Go.transform.localScale = cumulativeDelta;
Debug.Log(“Manipulation Started”);
}

void OnDestroy()
{
m_GestureRecognizer.ManipulationStartedEvent -= M_GestureRecognizer_ManipulationStartedEvent;
m_GestureRecognizer.ManipulationUpdatedEvent -= M_GestureRecognizer_ManipulationUpdatedEvent;
m_GestureRecognizer.ManipulationCompletedEvent -= M_GestureRecognizer_ManipulationCompletedEvent;
m_GestureRecognizer.ManipulationCanceledEvent -= M_GestureRecognizer_ManipulationCanceledEvent;

m_GestureRecognizer.StopCapturingGestures();
m_GestureRecognizer.Dispose();
}

}

Thank you,
Wesley