Beispiel #1
0
    private void ManipulationForOneHand()
    {
        if (FocusedObject == null || trackingHand.enabled == false || ObjectManipulationInProgress)
        {
            if (!ObjectManipulationInProgress)
            {
                UtilitiesScript.Instance.DisableOutline(FocusedObject);
            }

            return;
        }

        Vector3 handPos             = trackingHand.hand.transform.position; //The position of user's hand in the Holospace
        Bounds  focusedObjectBounds = focusedObjectRenderer.bounds;

        focusedObjectBounds.Expand(+0.02f);
        if (focusedObjectBounds.Contains(handPos))
        {
            ObjectTouched         = true;
            TouchedObject         = FocusedObject;
            touchedObjectRenderer = focusedObjectRenderer;
            //Refresh Outline
            if (!ColorOutlineChanged)
            {
                UtilitiesScript.Instance.ChangeObjectColor(trackingHand.hand, Color.green);
                UtilitiesScript.Instance.ChangeColorOutline(TouchedObject, Color.green);
                ColorOutlineChanged = true;
            }
            //Gather data
            if (DataCollectionMode)
            {
                dataScript.InteractionTouched(trackingHand.rightHand);
            }
        }
        else
        {
            float dd        = (FocusedObject.transform.position - trackingHand.hand.transform.position).magnitude * 5.0f;
            float lerpValue = (dd > 1.0f) ? 1.0f : dd;
            Debug.Log("Lerp.Value : " + lerpValue);
            Color tempColor = Color.Lerp(OutlineTouchedColor, OutlineHandAwayColor, lerpValue);
            UtilitiesScript.Instance.ChangeColorOutline(FocusedObject, tempColor);
            UtilitiesScript.Instance.ChangeObjectColor(trackingHand.hand, tempColor);
            ObjectTouched       = false;
            TouchedObject       = null;
            ColorOutlineChanged = false;
        }
    }