Exemple #1
0
        public override HandRepresentation MakeHandRepresentation(Leap.Hand hand, ModelType modelType)
        {
            HandRepresentation handRep = null;

            for (int i = 0; i < ModelPool.Count; i++)
            {
                IHandModel model = ModelPool[i];

                bool isCorrectHandedness;
                if (model.Handedness == Chirality.Either)
                {
                    isCorrectHandedness = true;
                }
                else
                {
                    Chirality handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
                    isCorrectHandedness = model.Handedness == handChirality;
                }

                bool isCorrectModelType;
                isCorrectModelType = model.HandModelType == modelType;

                if (isCorrectHandedness && isCorrectModelType)
                {
                    ModelPool.RemoveAt(i);
                    handRep = new HandProxy(this, model, hand);
                    break;
                }
            }
            return(handRep);
        }
 void ValidateIHandModelPrefab(IHandModel iHandModel)
 {
     if (PrefabUtility.GetPrefabType(iHandModel) == PrefabType.Prefab)
     {
         //EditorUtility.DisplayDialog("Warning", "This slot needs to have an instance of a prefab from your scene. Make your hand prefab a child of the LeapHanadContrller in your scene,  then drag here", "OK");
     }
 }
Exemple #3
0
 // Llamarlo cuando un evento active la atracción del cubo hacia la mano
 public void StartFollowHand(IHandModel handModel)
 {
     if (gameObject.activeSelf)
     {
         StartCoroutine(FollowHand(handModel));
     }
 }
 protected virtual void OnValidate()
 {
     if (_handModel == null)
     {
         _handModel = GetComponentInParent <IHandModel>();
     }
 }
Exemple #5
0
 void Awake()
 {
     if (HandModel == null)
     {
         HandModel = gameObject.GetComponentInParent <IHandModel>();
     }
     stateMachine = new GestureStateMachine(this);
 }
Exemple #6
0
    public void OnValidate()
    {
        IHandModel ihm = gameObject.GetComponentInParent <IHandModel>();

        if (ihm != null)
        {
            mano = (RigidHand)ihm;
        }
    }
        protected virtual void Awake()
        {
            IHandModel iHandModel = GetComponent <IHandModel>();

            if (iHandModel == null)
            {
                Debug.LogWarning("HandTransitionBehavior components require an IHandModel component attached to the same GameObject");
                return;
            }
            iHandModel.OnBegin  += HandReset;
            iHandModel.OnFinish += HandFinish;
        }
Exemple #8
0
 IEnumerator FollowHand(IHandModel hand)
 {
     for (;;)
     {
         Vector3 palmPosition = hand.GetLeapHand().PalmPosition.ToVector3();
         rb.AddForce((palmPosition - t.position) * force, ForceMode.Acceleration);
         if (rb.velocity.magnitude > maxVelocity)
         {
             rb.velocity = rb.velocity.normalized * maxVelocity;
         }
         yield return(null);
     }
 }
    protected virtual void OnValidate() {
      if (_handModel == null) {
        _handModel = GetComponentInParent<IHandModel>();
      }

      _activatePinchDist = Mathf.Max(0, _activatePinchDist);
      _deactivatePinchDist = Mathf.Max(0, _deactivatePinchDist);

      //Activate distance cannot be greater than deactivate distance
      if (_activatePinchDist > _deactivatePinchDist) {
        _deactivatePinchDist = _activatePinchDist;
      }
    }
    public HandProxy(HandPool parent, IHandModel handModel, Leap.Hand hand) :
      base(hand.Id)
    {
      this.parent = parent;
      this.handModel = handModel;

      // Check to see if the hand model has been initialized yet
      if (handModel.GetLeapHand() == null) {
        handModel.SetLeapHand(hand);
        handModel.InitHand();
      } else {
        handModel.SetLeapHand(hand);
      }
      handModel.BeginHand();
    }
        protected virtual void OnValidate()
        {
            if (_handModel == null)
            {
                _handModel = GetComponentInParent <IHandModel>();
            }

            _activatePinchDist   = Mathf.Max(0, _activatePinchDist);
            _deactivatePinchDist = Mathf.Max(0, _deactivatePinchDist);

            //Activate distance cannot be greater than deactivate distance
            if (_activatePinchDist > _deactivatePinchDist)
            {
                _deactivatePinchDist = _activatePinchDist;
            }
        }
Exemple #12
0
        public HandProxy(HandPool parent, IHandModel handModel, Leap.Hand hand) :
            base(hand.Id)
        {
            this.parent    = parent;
            this.handModel = handModel;

            // Check to see if the hand model has been initialized yet
            if (handModel.GetLeapHand() == null)
            {
                handModel.SetLeapHand(hand);
                handModel.InitHand();
            }
            else
            {
                handModel.SetLeapHand(hand);
            }
            handModel.BeginHand();
        }
Exemple #13
0
        public HandProxy(HandPool parent, IHandModel handModel, Leap.Hand hand)
            : base(hand.Id)
        {
            this.parent = parent;
              this.handModel = handModel;

              // Check to see if the hand model has been initialized yet
              if (handModel.GetLeapHand() == null) {
            handModel.SetLeapHand(hand);
            handModel.InitHand();
              } else {
            handModel.SetLeapHand(hand);
              }

              handFinishBehavior = handModel.GetComponent<HandTransitionBehavior>();
              if (handFinishBehavior) {
            handFinishBehavior.Reset();
              }
        }
Exemple #14
0
        public HandProxy(HandPool parent, IHandModel handModel, Leap.Hand hand) :
            base(hand.Id)
        {
            this.parent    = parent;
            this.handModel = handModel;

            // Check to see if the hand model has been initialized yet
            if (handModel.GetLeapHand() == null)
            {
                handModel.SetLeapHand(hand);
                handModel.InitHand();
            }
            else
            {
                handModel.SetLeapHand(hand);
            }


            handFinishBehavior = handModel.GetComponent <HandTransitionBehavior>();
            if (handFinishBehavior)
            {
                handFinishBehavior.Reset();
            }
        }
 public static float GetFingerDirection(IHandModel model, int i)
 {
     return((Quaternion.Inverse(model.GetLeapHand().Rotation.ToQuaternion()) * GetFinger(model, i).Direction.ToVector3()).z);
 }
Exemple #16
0
 /** To be called if the HandRepresentation no longer has a Leap Hand. */
 public override void Finish()
 {
     handModel.FinishHand();
     parent.ModelPool.Add(handModel);
     handModel = null;
 }
Exemple #17
0
 void ValidateIHandModelPrefab(IHandModel iHandModel)
 {
     if (PrefabUtility.GetPrefabType(iHandModel) == PrefabType.Prefab) {
     EditorUtility.DisplayDialog("Warning", "This slot needs to have an instance of a prefab from your scene. Make your hand prefab a child of the LeapHanadContrller in your scene,  then drag here", "OK");
       }
 }
 private static Leap.Finger GetFinger(IHandModel model, int i)
 {
     return(model.GetLeapHand().Fingers[i]);
 }
 /** To be called if the HandRepresentation no longer has a Leap Hand. */
 public override void Finish() {
   handModel.FinishHand();
   parent.ModelPool.Add(handModel);
   handModel = null;
 }