Beispiel #1
0
    private void ActivatingStateHandler()
    {
        // Fade in the hand
        Color opaqe = new Color(0, 0, 0, 1f);
        Tween tween = HandModel.materials[1].DOColor(opaqe, "_BaseColor", 0.5f).SetOptions(true);

        // Check if base hand was grasping an object when it entered the proxy
        if (Player.Instance.GetInteractionHand(HandChirality).isGraspingObject)
        {
            // Create a duplicate at mark hand location if the base hand was grasping an object
            baseHandObject = Player.Instance.GetInteractionHand(HandChirality).graspedObject.gameObject.GetComponent <InteractionWorldObject>();
            ProxyNode proxy = LeapProvider.GetProxyNode(HandChirality);
            // Scale the grasped object to appropriate size
            Vector3 relativeScale = new Vector3(
                proxy.transform.localScale.x / Mark.transform.localScale.x,
                proxy.transform.localScale.y / Mark.transform.localScale.y,
                proxy.transform.localScale.z / Mark.transform.localScale.z
                );
            baseHandObject.ScaleAroundGraspRel(relativeScale);
            // Instatniate a duplicate at mark location
            markHandObject = baseHandObject.InstantiateDuplicate(proxy.transform, Mark.transform);
            ownership      = Ownership.BaseHand;
            ChangeState(MarkHandState.DuplicateObject);
        }
        else     // If the base hand wasn not grasping an object go to Idle state
        {
            ChangeState(MarkHandState.Idle);
        }
    }
Beispiel #2
0
 private void IdleStateHandler()
 {
     if (!isEnabled)
     {
         ChangeState(MarkHandState.Deactivating);
     }
     if (interactionHand.isGraspingObject)
     {
         // Duplicate the object at base hand's location
         markHandObject = interactionHand.graspedObject.transform.GetComponent <InteractionWorldObject>();
         baseHandObject = markHandObject.InstantiateDuplicate(Mark.transform, LeapProvider.GetProxyNode(HandChirality).transform);
         ownership      = Ownership.MarkHand;
         ChangeState(MarkHandState.GraspingObject);
     }
 }
Beispiel #3
0
 private void GraspingObjectStateHandler()
 {
     if (!isEnabled)
     {
         ChangeState(MarkHandState.Deactivating);
     }
     else if (interactionHand.graspedObject == null)
     {
         // Destroy the object at base hand's location
         baseHandObject.Destroy();
         baseHandObject = null;
         markHandObject = null;
         ownership      = Ownership.None;
         ChangeState(MarkHandState.Idle);
     }
 }
Beispiel #4
0
 private void DuplicateObjectStateHandler()
 {
     // Base hand releases the grasped object while in the proxy
     if (!Player.Instance.GetInteractionHand(HandChirality).isGraspingObject)
     {
         // Destroy the object that was grasped by the base hand and keep the duplicate
         markHandObject.GetComponent <Rigidbody>().isKinematic = false;
         //markHandObject.GetComponent<HighlightController>().enabled = true;
         markHandObject = null;
         baseHandObject.Destroy();
         baseHandObject = null;
         ownership      = Ownership.None;
         ChangeState(MarkHandState.Idle);
     }
     if (!isEnabled)
     {
         ChangeState(MarkHandState.Deactivating);
     }
 }
Beispiel #5
0
    // Hacky, basically this one waits for the fading to be completed
    // and then handles everything else.
    IEnumerator HandFadeOut()
    {
        // Fade out the hand
        Color transparent = new Color(0, 0, 0, 0f);
        Tween tween       = HandModel.materials[1].DOColor(transparent, "_BaseColor", 0.8f).SetOptions(true);

        yield return(tween.WaitForCompletion());

        /* Fading finished */
        // If marked hand is grasping an object destroy it
        if (markHandObject != null)
        {
            // Transfer ownership first
            if (ownership == Ownership.MarkHand)
            {
                markHandObject.TransferOwnership();
            }
            markHandObject.Destroy();
        }
        baseHandObject = null;
        LeapProvider.EnableHand(false, HandChirality);
        handFadeOutCoroutine = null;
        ChangeState(MarkHandState.Disabled);
    }