Example #1
0
    private static float MIN_FINGER_TO_PALM_DISTANCE = 0.040f;//0.045f;

    void Start()
    {
        this.CurrentGraspState        = GraspState.RELEASED;
        this.ActiveObject             = null;
        this.ObjectMaxAngularVelocity = 0.0f;
        this.RotationFromPalm         = Quaternion.identity;
        this.CurrentGraspCenter       = Vector3.zero;
        this.SmoothedGraspPosition    = Vector3.zero;
        this.GraspOffset  = Vector3.zero;
        this.PalmRotation = Quaternion.identity;

        this.ReleaseStrengthCurve = new AnimationCurve();
        this.ReleaseStrengthCurve.AddKey(new Keyframe(0.0f, 1.0f));
        this.ReleaseStrengthCurve.AddKey(new Keyframe(1.001355f, -0.0007067919f));

        GameObject container = GameObject.FindGameObjectWithTag("Container");

        if (container != null)
        {
            /*ContainerController containerController = container.GetComponent<ContainerController>();
             * if (containerController != null)
             * {
             * //containerController.ObjectWasReleased += new ContainerController.ObjectWasReleasedHandler(this.checkRelease);
             * containerController.ObjectWasReleased += (this.checkRelease);
             * }
             */
        }
    }
Example #2
0
    /*
     * void Update()
     * {
     * HandModel handModel = this.GetComponent<HandModel>();
     * Hand leapHand = handModel.GetLeapHand();
     * GameObject info = GameObject.Find("FeedbackDisplay");
     * Vector3 centroid = leapHand.Fingers[1].TipPosition.ToUnityScaled() * .25f + leapHand.Fingers[2].TipPosition.ToUnityScaled() * .25f + leapHand.Fingers[3].TipPosition.ToUnityScaled() * .25f + leapHand.Fingers[4].TipPosition.ToUnityScaled() * .25f;
     * float distance = Vector3.Distance(leapHand.PalmPosition.ToUnityScaled(), centroid);
     * info.GetComponent<UnityEngine.UI.Text>().text = leapHand.GrabStrength.ToString() + "\n" + this.CurrentGraspState + "\n " + distance;
     * }
     */
    /*
     * void Update()
     * {
     *  HandModel handModel = this.GetComponent<HandModel>();
     *  Vector3 axis = handModel.GetPalmDirection();
     *
     *  for (int i = 1; i < 5; i++)
     *  {
     *      Vector3 fingerAxis = handModel.fingers[i].GetRay().direction;
     *      float angle = Vector3.Angle(axis, fingerAxis);
     *      UnityEngine.Debug.Log(i + ": " + angle + " :" + handModel.GetLeapHand().GrabStrength);
     *  }
     * }
     */
    void FixedUpdate()
    {
        this.UpdatePalmRotation();
        this.UpdateGraspPosition();
        HandModel handModel = this.GetComponent <HandModel>();
        Hand      leapHand  = handModel.GetLeapHand();

        if (leapHand == null)
        {
            return;
        }

        GraspState newGraspState = this.GetNewGraspState();

        if (this.CurrentGraspState == GraspState.GRASPED)
        {
            if (newGraspState == GraspState.RELEASED)
            {
                this.OnRelease();
            }
            else if (this.ActiveObject != null)
            {
                this.ContinueHardGrasp();
            }
        }
        else if (this.CurrentGraspState == GraspState.RELEASING)
        {
            if (newGraspState == GraspState.RELEASED)
            {
                this.OnRelease();
            }
            else if (newGraspState == GraspState.GRASPED)
            {
                this.StartGrasp();
            }
            else if (this.ActiveObject != null)
            {
                this.ContinueSoftGrasp();
            }
        }
        else
        {
            if (newGraspState == GraspState.GRASPED)
            {
                this.StartGrasp();
            }
            else
            {
                this.Hover();
            }
        }
        this.CurrentGraspState = newGraspState;
    }
Example #3
0
 public void requestRelease()
 {
     this.CurrentGraspState = GraspState.RELEASED;
     this.OnRelease();
 }