SetLeapHand() public method

public SetLeapHand ( Hand, hand ) : void
hand Hand,
return void
Exemplo n.º 1
0
    private void DestroyHand(HandModel hand_model)
    {
        if (destroyHands)
        {
            // Cleans up mirror hand object on deletion of its respective hand
            if (hand_model.gameObject.name == "RigidHand(Clone)")
            {
                int        handID = hand_model.GetLeapHand().Id;
                GameObject refObj = GameObject.Find(handID.ToString());
                // Detaches children to prevent deleting an object currently moving with the hand
                GameObject cubes = GameObject.Find("Cubes");

                if (refObj != null)
                {
//					refObj.transform.DetachChildren();
//					if(refObj.transform.childCount > 0){
//						refObj.transform.GetChild(0).parent = cubes.transform;
//					}
                    for (int i = 0; i < cubes.transform.childCount; i++)
                    {
                        cubes.transform.GetChild(i).gameObject.renderer.material.color = Color.gray;
                    }
                }
            }

            Destroy(hand_model.gameObject);
        }
        else
        {
            hand_model.SetLeapHand(null);
        }
    }
Exemplo n.º 2
0
    private void UpdateHandModels(Dictionary <int, HandModel> all_hands,
                                  HandList leap_hands,
                                  HandModel left_model, HandModel right_model)
    {
        List <int> ids_to_check = new List <int>(all_hands.Keys);

        // Go through all the active hands and update them.
        int num_hands = leap_hands.Count;

        for (int h = 0; h < num_hands; ++h)
        {
            Hand leap_hand = leap_hands[h];

            HandModel model = leap_hand.IsLeft? left_model : right_model;
            // Only create or update if the hand is enabled.
            if (model != null)
            {
                ids_to_check.Remove(leap_hand.Id);

                // Create the hand and initialized it if it doesn't exist yet.
                if (!all_hands.ContainsKey(leap_hand.Id))
                {
                    HandModel new_hand = CreateHand(model);
                    new_hand.SetLeapHand(leap_hand);
                    new_hand.SetController(this);

                    // Set scaling based on reference hand.
                    float hand_scale = leap_hand.PalmWidth / MODEL_PALM_WIDTH;
                    new_hand.transform.localScale = hand_scale * transform.localScale;

                    new_hand.InitHand();
                    new_hand.UpdateHand();
                    all_hands[leap_hand.Id] = new_hand;
                }
                else
                {
                    // Make sure we update the Leap Hand reference.
                    HandModel hand_model = all_hands[leap_hand.Id];
                    hand_model.SetLeapHand(leap_hand);

                    // Set scaling based on reference hand.
                    float hand_scale = leap_hand.PalmWidth / MODEL_PALM_WIDTH;
                    hand_model.transform.localScale = hand_scale * transform.localScale;
                    hand_model.UpdateHand();
                }
            }
        }

        // Destroy all hands with defunct IDs.
        for (int i = 0; i < ids_to_check.Count; ++i)
        {
            Destroy(all_hands[ids_to_check[i]].gameObject);
            all_hands.Remove(ids_to_check[i]);
        }
    }
Exemplo n.º 3
0
 /**
  * Destroys a HandModel instance if HandController.destroyHands is true (the default).
  * If you set destroyHands to false, you must destroy the hand instances elsewhere in your code.
  */
 protected void DestroyHand(HandModel hand_model)
 {
     if (destroyHands)
     {
         Destroy(hand_model.gameObject);
     }
     else
     {
         hand_model.SetLeapHand(null);
     }
 }
Exemplo n.º 4
0
    /**
     * Destroys a HandModel instance if HandController.destroyHands is true (the default).
     * If you set destroyHands to false, you must destroy the hand instances elsewhere in your code.
     */
    protected void DestroyHand(HandModel hand_model)
    {
        handEvent handHandler = onDestroyHand;

        if (handHandler != null)
        {
            handHandler(hand_model);
        }
        if (destroyHands)
        {
            Destroy(hand_model.gameObject);
        }
        else
        {
            hand_model.SetLeapHand(null);
        }
    }
Exemplo n.º 5
0
 /// <summary>
 /// Tells the hands to update to match the new Leap Motion hand frame data. Also keeps track of
 /// which hands are currently active.
 /// </summary>
 void UpdateHandRepresentations()
 {
     leftActive  = false;
     rightActive = false;
     foreach (Leap.Hand curHand in provider.CurrentFrame.Hands)
     {
         if (curHand.IsLeft)
         {
             leftHand.SetLeapHand(curHand);
             leftHand.UpdateHand();
             leftActive = true;
         }
         if (curHand.IsRight)
         {
             rightHand.SetLeapHand(curHand);
             rightHand.UpdateHand();
             rightActive = true;
         }
     }
 }
Exemplo n.º 6
0
    /** Creates a new HandModel instance. */
    protected HandModel CreateHand(Hand leap_hand, HandModel model)
    {
        HandModel hand_model = Instantiate(model, transform.position, transform.rotation)
                               as HandModel;

        hand_model.gameObject.SetActive(true);
        Leap.Utils.IgnoreCollisions(hand_model.gameObject, gameObject);
        hand_model.transform.SetParent(transform);
        hand_model.SetLeapHand(leap_hand);
        hand_model.MirrorZAxis(mirrorZAxis);
        hand_model.SetController(this);

        handEvent handHandler = onCreateHand;

        if (handHandler != null)
        {
            handHandler(hand_model);
        }

        return(hand_model);
    }
Exemplo n.º 7
0
    /** Creates a new HandModel instance. */
    protected HandModel CreateHand(Hand leap_hand, HandModel model)
    {
        HandModel hand_model = Instantiate(model, transform.position, transform.rotation)
                               as HandModel;

        hand_model.gameObject.SetActive(true);
        Leap.Utils.IgnoreCollisions(hand_model.gameObject, gameObject);
        hand_model.transform.SetParent(transform);
        hand_model.SetLeapHand(leap_hand);
        hand_model.MirrorZAxis(mirrorZAxis);
        hand_model.SetController(this);

        //Marcamos con la etiqueta "Manos" para una posterior detección por colisiones
        hand_model.gameObject.tag = "Manos";

        handEvent handHandler = onCreateHand;

        if (handHandler != null)
        {
            handHandler(hand_model);
        }

        return(hand_model);
    }
Exemplo n.º 8
0
 /**
   * Destroys a HandModel instance if HandController.destroyHands is true (the default).
   * If you set destroyHands to false, you must destroy the hand instances elsewhere in your code.
   */
 protected void DestroyHand(HandModel hand_model)
 {
     handEvent handHandler = onDestroyHand;
     if (handHandler != null) {
       handHandler(hand_model);
     }
     if (destroyHands)
       Destroy(hand_model.gameObject);
     else
       hand_model.SetLeapHand(null);
 }
Exemplo n.º 9
0
    /**
     * Updates hands based on tracking data in the specified Leap HandList object.
     * Active HandModel instances are updated if the hand they represent is still
     * present in the Leap HandList; otherwise, the HandModel is removed. If new
     * Leap Hand objects are present in the Leap HandList, new HandModels are
     * created and added to the HandController hand list.
     * @param all_hands The dictionary containing the HandModels to update.
     * @param leap_hands The list of hands from the a Leap Frame instance.
     * @param left_model The HandModel instance to use for new left hands.
     * @param right_model The HandModel instance to use for new right hands.
     */
    protected void UpdateHandModels(Dictionary <int, HandModel> all_hands,
                                    HandList leap_hands,
                                    HandModel left_model, HandModel right_model)
    {
        List <int> ids_to_check = new List <int>(all_hands.Keys);

        // Go through all the active hands and update them.
        int num_hands = leap_hands.Count;

        for (int h = 0; h < num_hands; ++h)
        {
            Hand leap_hand = leap_hands[h];

            HandModel model = (mirrorZAxis != leap_hand.IsLeft) ? left_model : right_model;

            // If we've mirrored since this hand was updated, destroy it.
            if (all_hands.ContainsKey(leap_hand.Id) &&
                all_hands[leap_hand.Id].IsMirrored() != mirrorZAxis)
            {
                DestroyHand(all_hands[leap_hand.Id]);
                all_hands.Remove(leap_hand.Id);
            }

            // Only create or update if the hand is enabled.
            if (model != null)
            {
                ids_to_check.Remove(leap_hand.Id);

                // Create the hand and initialized it if it doesn't exist yet.
                if (!all_hands.ContainsKey(leap_hand.Id))
                {
                    HandModel new_hand = CreateHand(model);
                    new_hand.SetLeapHand(leap_hand);
                    new_hand.MirrorZAxis(mirrorZAxis);
                    new_hand.SetController(this);

                    // Set scaling based on reference hand.
                    float hand_scale = MM_TO_M * leap_hand.PalmWidth / new_hand.handModelPalmWidth;
                    new_hand.transform.localScale = hand_scale * transform.lossyScale;

                    new_hand.InitHand();
                    new_hand.UpdateHand();
                    all_hands[leap_hand.Id] = new_hand;
                }
                else
                {
                    // Make sure we update the Leap Hand reference.
                    HandModel hand_model = all_hands[leap_hand.Id];
                    hand_model.SetLeapHand(leap_hand);
                    hand_model.MirrorZAxis(mirrorZAxis);

                    // Set scaling based on reference hand.
                    float hand_scale = MM_TO_M * leap_hand.PalmWidth / hand_model.handModelPalmWidth;
                    hand_model.transform.localScale = hand_scale * transform.lossyScale;
                    hand_model.UpdateHand();
                }
            }
        }

        // Destroy all hands with defunct IDs.
        for (int i = 0; i < ids_to_check.Count; ++i)
        {
            DestroyHand(all_hands[ids_to_check[i]]);
            all_hands.Remove(ids_to_check[i]);
        }
    }
 private void DestroyHand(HandModel hand_model) {
   if (destroyHands)
     Destroy(hand_model.gameObject);
   else
     hand_model.SetLeapHand(null);
 }
    new protected void UpdateHandModels(Dictionary <int, HandModel> all_hands,
                                        HandList leap_hands,
                                        HandModel left_model, HandModel right_model)
    {
        List <int> ids_to_check = new List <int>(all_hands.Keys);

        // Go through all the active hands and update them.
        int num_hands = leap_hands.Count;

        for (int h = 0; h < num_hands; ++h)
        {
            Hand leap_hand = leap_hands[h];

            HandModel model = (mirrorZAxis != leap_hand.IsLeft) ? left_model : right_model;

            // hmm, quite stupid way to keep track of the right hand ID...
            if (leap_hand.IsRight && !(right_model.GetType() == typeof(RigidHand)))
            {
                this.currentRightHandID = leap_hand.Id;
            }

            // If we've mirrored since this hand was updated, destroy it.
            if (all_hands.ContainsKey(leap_hand.Id) &&
                all_hands[leap_hand.Id].IsMirrored() != mirrorZAxis)
            {
                DestroyHand(all_hands[leap_hand.Id]);
                all_hands.Remove(leap_hand.Id);
            }

            // Only create or update if the hand is enabled.
            if (model != null)
            {
                ids_to_check.Remove(leap_hand.Id);

                // Create the hand and initialized it if it doesn't exist yet.
                if (!all_hands.ContainsKey(leap_hand.Id))
                {
                    HandModel new_hand = CreateHand(model);
                    new_hand.SetLeapHand(leap_hand);
                    new_hand.MirrorZAxis(mirrorZAxis);
                    new_hand.SetController(this);

                    // Set scaling based on reference hand.
                    float hand_scale = MM_TO_M * leap_hand.PalmWidth / new_hand.handModelPalmWidth;
                    new_hand.transform.localScale = hand_scale * transform.lossyScale;

                    new_hand.InitHand();
                    new_hand.UpdateHand();
                    all_hands[leap_hand.Id] = new_hand;
                    if (leap_hand.Id == this.currentRightHandID)
                    {
                        this.currentRelevantPalmPosition = all_hands[leap_hand.Id].GetPalmPosition();
                        foreach (FingerModel finger in all_hands[leap_hand.Id].fingers)
                        {
                            if (finger.fingerType == Finger.FingerType.TYPE_INDEX)
                            {
                                this.currentRelevantIndexPosition = finger.GetTipPosition();
                            }
                            else if (finger.fingerType == Finger.FingerType.TYPE_THUMB)
                            {
                                this.currentRelevantThumbPosition = finger.GetTipPosition();
                            }
                        }
                    }
                }
                else
                {
                    // Make sure we update the Leap Hand reference.
                    HandModel hand_model = all_hands[leap_hand.Id];
                    hand_model.SetLeapHand(leap_hand);
                    hand_model.MirrorZAxis(mirrorZAxis);

                    // Set scaling based on reference hand.
                    float hand_scale = MM_TO_M * leap_hand.PalmWidth / hand_model.handModelPalmWidth;
                    hand_model.transform.localScale = hand_scale * transform.lossyScale;
                    hand_model.UpdateHand();
                    if (leap_hand.Id == this.currentRightHandID)
                    {
                        this.currentRelevantPalmPosition = all_hands[leap_hand.Id].GetPalmPosition();
                        foreach (FingerModel finger in all_hands[leap_hand.Id].fingers)
                        {
                            if (finger.fingerType == Finger.FingerType.TYPE_INDEX)
                            {
                                this.currentRelevantIndexPosition = finger.GetTipPosition();
                            }
                            else if (finger.fingerType == Finger.FingerType.TYPE_THUMB)
                            {
                                this.currentRelevantThumbPosition = finger.GetTipPosition();
                            }
                        }
                    }
                }
            }
        }

        // Destroy all hands with defunct IDs.
        for (int i = 0; i < ids_to_check.Count; ++i)
        {
            DestroyHand(all_hands[ids_to_check[i]]);
            all_hands.Remove(ids_to_check[i]);
            if (ids_to_check[i] == this.currentRightHandID)
            {
                this.currentRightHandID = -1;
            }
        }
    }
Exemplo n.º 12
0
    /**
      * Destroys a HandModel instance if HandController.destroyHands is true (the default).
      * If you set destroyHands to false, you must destroy the hand instances elsewhere in your code.
      * EDIT BV : put back the hands in the initial position
      */
    protected void DestroyHand(HandModel hand_model)
    {
        if (hand_model.GetLeapHand().IsLeft) {
            lefthand = null;
            //Debug.Log("DestroyHand: minus left hand");
        } else {
            righthand = null;
            //Debug.Log("DestroyHand: minus right hand");
        }

        if (destroyHands)
            Destroy(hand_model.gameObject);
        else
            hand_model.SetLeapHand(null);
        //Debug.Log("DestroyHand " + hand_model);
    }
Exemplo n.º 13
0
    private void UpdateHandModels(Dictionary <int, HandModel> all_hands,
                                  HandList leap_hands,
                                  HandModel left_model, HandModel right_model)
    {
        List <int> ids_to_check = new List <int>(all_hands.Keys);

        // Go through all the active hands and update them.
        int num_hands = leap_hands.Count;

        if (num_hands == 0)
        {
            RightMostHandPosition = LeftMostHandPosition = 0;
        }
        for (int h = 0; h < num_hands; ++h)
        {
            Hand leap_hand = leap_hands[h];

            HandModel model = leap_hand.IsLeft? left_model : right_model;

            // Only create or update if the hand is enabled.
            if (model != null)
            {
                ids_to_check.Remove(leap_hand.Id);

                // Create the hand and initialized it if it doesn't exist yet.
                if (!all_hands.ContainsKey(leap_hand.Id))
                {
                    HandModel new_hand = CreateHand(model);
                    new_hand.SetLeapHand(leap_hand);
                    new_hand.SetController(this);

                    // Set scaling based on reference hand.
                    float hand_scale = leap_hand.PalmWidth / MODEL_PALM_WIDTH;
                    new_hand.transform.localScale = hand_scale * transform.localScale;

                    new_hand.InitHand();
                    new_hand.UpdateHand();
                    all_hands[leap_hand.Id] = new_hand;
                    model = new_hand;
                }
                else
                {
                    // Make sure we update the Leap Hand reference.
                    HandModel hand_model = all_hands[leap_hand.Id];
                    hand_model.SetLeapHand(leap_hand);

                    // Set scaling based on reference hand.
                    float hand_scale = leap_hand.PalmWidth / MODEL_PALM_WIDTH;
                    hand_model.transform.localScale = hand_scale * transform.localScale;

                    hand_model.UpdateHand();
                    model = hand_model;
                }
                if (h == 0)
                {
                    RightMostHandPosition = LeftMostHandPosition = model.GetPalmPosition().x;
                }
                RightMostHandPosition = model.GetPalmPosition().x > RightMostHandPosition?model.GetPalmPosition().x : RightMostHandPosition;

                LeftMostHandPosition = model.GetPalmPosition().x < LeftMostHandPosition?model.GetPalmPosition().x : LeftMostHandPosition;
            }
        }
        InterpolateKeys.UpdateHands(num_hands);
        // Destroy all hands with defunct IDs.
        for (int i = 0; i < ids_to_check.Count; ++i)
        {
            Destroy(all_hands[ids_to_check[i]].gameObject);
            all_hands.Remove(ids_to_check[i]);
        }

        if (DateTime.Now.Subtract(prevLogTime).TotalSeconds >= 1)
        {
            prevLogTime = DateTime.Now;
            if (LeftMostHandPosition < LeftBorder && RightMostHandPosition > RightBorder)
            {
                return;
            }

            Main.CameraTargetPos = Camera.main.transform.position;

            if (LeftMostHandPosition < LeftBorder)
            {
                Tools.ShiftView(Tools.Direction.Left);
            }
            if (RightMostHandPosition > RightBorder)
            {
                Tools.ShiftView(Tools.Direction.Right);
            }
        }
    }
        /**
         * Makes sure the physics hands are instantiated or updated as required
         * */
        protected void UpdatePhysicsHandModels(Dictionary <int, HandModel> all_hands,
                                               HandList leap_hands,
                                               HandModel left_model, HandModel right_model)
        {
            List <int> ids_to_check = new List <int>(all_hands.Keys);

            // Go through all the active hands and update them.
            int num_hands = leap_hands.Count;

            for (int h = 0; h < num_hands; ++h)
            {
                Hand leap_hand = leap_hands[h];

                HandModel model = (mirrorZAxis != leap_hand.IsLeft) ? left_model : right_model;

                // If we've mirrored since this hand was updated, destroy it.
                if (all_hands.ContainsKey(leap_hand.Id) &&
                    all_hands[leap_hand.Id].IsMirrored() != mirrorZAxis)
                {
                    DestroyHand(all_hands[leap_hand.Id]);
                    all_hands.Remove(leap_hand.Id);
                }

                // Only create or update if the hand is enabled.
                if (model != null)
                {
                    ids_to_check.Remove(leap_hand.Id);
                    // Create the hand and initialized it if it doesn't exist yet.
                    if (!all_hands.ContainsKey(leap_hand.Id))
                    {
                        HandModel new_hand = CreateHand(model, leap_hand.IsLeft);
                        new_hand.SetLeapHand(leap_hand);
                        new_hand.MirrorZAxis(mirrorZAxis);
                        new_hand.SetController(this);

                        // Set scaling based on reference hand.
                        float hand_scale = MM_TO_M * leap_hand.PalmWidth / new_hand.handModelPalmWidth;
                        new_hand.transform.localScale = hand_scale * transform.lossyScale;

                        all_hands[leap_hand.Id] = new_hand;                     //bugfix: adding to list before init/update, because if it errors during that process then it'll never get into the list and thus never be removed...
                        new_hand.InitHand();
                        new_hand.UpdateHand();

                        //Debug.Log ("Added " + leap_hand.Id + " to physics list");
                        //Debug.Log ("Created a physics hand and added to active physics hands list, now contains " + all_hands.Count + " hands");
                    }
                    else
                    {
                        //Debug.Log ("Updated a physics hand");
                        // Make sure we update the Leap Hand reference.
                        HandModel hand_model = all_hands[leap_hand.Id];
                        hand_model.SetLeapHand(leap_hand);
                        hand_model.MirrorZAxis(mirrorZAxis);

                        // Set scaling based on reference hand.
                        float hand_scale = MM_TO_M * leap_hand.PalmWidth / hand_model.handModelPalmWidth;
                        hand_model.transform.localScale = hand_scale * transform.lossyScale;
                        hand_model.UpdateHand();
                    }
                }
            }

            // Destroy all hands with defunct IDs.
            for (int i = 0; i < ids_to_check.Count; ++i)
            {
                DestroyHand(all_hands[ids_to_check[i]]);
                //Debug.Log ("Destroyed " + ids_to_check[i] + " from physics list because it was defunct");
                all_hands.Remove(ids_to_check[i]);
            }
        }
        /**
         * Updates the graphics hands so that they're drawn properly
         * */
        protected new void UpdateHandModels(Dictionary <int, HandModel> all_hands,
                                            HandList leap_hands,
                                            HandModel left_model, HandModel right_model)
        {
            List <int> ids_to_check = new List <int>(all_hands.Keys);

            // Go through all the active hands in the Leap motion frame and update them.
            int num_hands = leap_hands.Count;

            for (int h = 0; h < num_hands; ++h)
            {
                Hand leap_hand = leap_hands[h];

                HandModel model = (mirrorZAxis != leap_hand.IsLeft) ? left_model : right_model;

                // Only create or update if the hand is enabled.
                if (model != null)
                {
                    ids_to_check.Remove(leap_hand.Id);                  //this prevents the hand from being made inactive, since it is active.

                    // Create the hand and initialized it if it doesn't exist yet.
                    if (!all_hands.ContainsKey(leap_hand.Id))
                    {
                        HandModel new_hand = InitializeHand(model);                     //We don't instantiate these ones - they're already on the avatar, so we just init them instead of CreateHand them
                        new_hand.SetLeapHand(leap_hand);
                        new_hand.MirrorZAxis(mirrorZAxis);
                        new_hand.SetController(this);

                        // Set scaling based on reference hand.
                        float hand_scale = MM_TO_M * leap_hand.PalmWidth / new_hand.handModelPalmWidth;
                        new_hand.transform.localScale = hand_scale * transform.lossyScale;

                        new_hand.InitHand();
                        new_hand.UpdateHand();
                        all_hands[leap_hand.Id] = new_hand;

                        if (new_hand.GetLeapHand().IsLeft)
                        {
                            leftActive = true;
                        }
                        else
                        {
                            rightActive = true;
                        }
                        //Debug.Log ("Initialised graphics hand and added to active hands list, now contains " + all_hands.Count + " hands");
                    }
                    else
                    {
                        // Make sure we update the Leap Hand reference.
                        HandModel hand_model = all_hands[leap_hand.Id];
                        hand_model.SetLeapHand(leap_hand);
                        hand_model.MirrorZAxis(mirrorZAxis);

                        // Set scaling based on reference hand.
                        float hand_scale = MM_TO_M * leap_hand.PalmWidth / hand_model.handModelPalmWidth;
                        hand_model.transform.localScale = hand_scale * transform.lossyScale;
                        hand_model.UpdateHand();

                        if (hand_model.GetLeapHand().IsLeft)
                        {
                            leftActive = true;
                        }
                        else
                        {
                            rightActive = true;
                        }
                        //Debug.Log ("Updated graphics hand");
                    }
                }
            }

            // flag hands that are no longer active, so IK knows to turn off
            for (int i = 0; i < ids_to_check.Count; ++i)
            {
                if (all_hands[ids_to_check[i]].GetLeapHand().IsLeft)
                {
                    leftActive = false;
                }
                else
                {
                    rightActive = false;
                }
                all_hands.Remove(ids_to_check[i]);
            }
        }
Exemplo n.º 16
0
    /**
     * Updates hands based on tracking data in the specified Leap HandList object.
     * Active HandModel instances are updated if the hand they represent is still
     * present in the Leap HandList; otherwise, the HandModel is removed. If new
     * Leap Hand objects are present in the Leap HandList, new HandModels are
     * created and added to the HandController hand list.
     * @param all_hands The dictionary containing the HandModels to update.
     * @param leap_hands The list of hands from the a Leap Frame instance.
     * @param left_model The HandModel instance to use for new left hands.
     * @param right_model The HandModel instance to use for new right hands.
     */
    protected void UpdateHandModels(Dictionary <int, HandModel> all_hands,
                                    HandList leap_hands,
                                    HandModel left_model, HandModel right_model)
    {
        List <int> ids_to_check = new List <int> (all_hands.Keys);

        // Go through all the active hands and update them.
        int num_hands = leap_hands.Count;

        for (int h = 0; h < num_hands; ++h)
        {
            Hand leap_hand = leap_hands [h];

            //Get the finger_tip location if finger is pinched
            if (leap_hand.PinchStrength > 0.2)
            {
                if (linePoints.Count == 0)
                {
                    lineRenderer.SetVertexCount(0);
                }

                FingerList point   = leap_hand.Fingers.FingerType(Finger.FingerType.TYPE_INDEX);
                Vector3    new_tip = UnityVectorExtension.ToUnity(point [0].TipPosition);
                new_tip.x = new_tip.x * 1.5f;



                lineRenderer.SetPosition(lineRenderer.positionCount - 1, new_tip);

                lineRenderer.positionCount = lineRenderer.positionCount + 1;
                lineRenderer.SetPosition(lineRenderer.positionCount - 1, new_tip);
                linePoints.Add(new_tip);
                Debug.Log("pinching: " + linePoints.Count);
                //Debug.Log (linePoints [linePoints.Count - 1]);
                if (numPoint % 15 == 0)
                {
                    lineRenderer.Simplify(.1f);
                }
                numPoint++;
            }
            else
            {
                //transform.Translate(Vector3.up * Time.deltaTime*50);

                if (linePoints.Count > 0)
                {
                    Debug.Log("not pinching: " + convertVectorListToString(linePoints) + linePoints.Count);
                    StartCoroutine(GetText());
                    //lineRenderer = gameObject.AddComponent<LineRenderer> ();
                    //lineRenderer.positionCount = 100;

                    tex = new Texture2D(128, 128);

                    string fromBase64 = equaIMG;
                    byte[] data       = System.Convert.FromBase64String(fromBase64);
                    tex.LoadImage(data);


                    cube = GameObject.Find("Cube");
                    cube.transform.position   = new Vector3(0, -100, 0);
                    cube.transform.localScale = new Vector3(tex.width * 2, tex.height * 2, 10);
                    //cube.transform.Rotate(new Vector3(0, 0, 180));

                    m_Material             = cube.GetComponent <Renderer> ().material;
                    m_Material.mainTexture = tex;


                    linePoints.Clear();
                    lineRenderer.SetVertexCount(0);

                    //lineRenderer = GetComponent<LineRenderer>();
                    lineRenderer.positionCount = equaPoints.Count;
                    lineRenderer.SetPositions(equaPoints.ToArray());
                }
                else
                {
                }
                int b = checkSwipe(leap_hand);
                if (b != 0)
                {
                    curAngle     = b * 30 * Time.deltaTime;
                    cameraObj    = GameObject.Find("Main Camera");
                    rotateAround = GameObject.Find("HandController").GetComponent <Transform> ();

                    cameraObj.transform.LookAt(rotateAround.position);
                    cameraObj.transform.RotateAround(rotateAround.position, Vector3.up, curAngle);                     //.5f);
                    //lineRenderer.transform.RotateAround(Vector3.zero, Vector3.up, b*30 * Time.deltaTime);
                }



                HandModel model = (mirrorZAxis != leap_hand.IsLeft) ? left_model : right_model;

                // If we've mirrored since this hand was updated, destroy it.
                if (all_hands.ContainsKey(leap_hand.Id) &&
                    all_hands [leap_hand.Id].IsMirrored() != mirrorZAxis)
                {
                    DestroyHand(all_hands [leap_hand.Id]);
                    all_hands.Remove(leap_hand.Id);
                }

                // Only create or update if the hand is enabled.
                if (model != null)
                {
                    ids_to_check.Remove(leap_hand.Id);
                    // Create the hand and initialized it if it doesn't exist yet.
                    if (!all_hands.ContainsKey(leap_hand.Id))
                    {
                        HandModel new_hand = CreateHand(model);
                        new_hand.SetLeapHand(leap_hand);
                        new_hand.MirrorZAxis(mirrorZAxis);
                        new_hand.SetController(this);

                        // Set scaling based on reference hand.
                        float hand_scale = MM_TO_M * leap_hand.PalmWidth / new_hand.handModelPalmWidth;
                        new_hand.transform.localScale = hand_scale * transform.lossyScale;
                        //new_hand.transform.RotateAround(Vector3.zero, Vector3.up, -curAngle);
                        new_hand.InitHand();

                        new_hand.UpdateHand();
                        all_hands [leap_hand.Id] = new_hand;
                    }
                    else
                    {
                        // Make sure we update the Leap Hand reference.
                        HandModel hand_model = all_hands [leap_hand.Id];
                        hand_model.SetLeapHand(leap_hand);
                        hand_model.MirrorZAxis(mirrorZAxis);

                        // Set scaling based on reference hand.
                        float hand_scale = MM_TO_M * leap_hand.PalmWidth / hand_model.handModelPalmWidth;
                        hand_model.transform.localScale = hand_scale * transform.lossyScale;
                        hand_model.UpdateHand();
                    }
                }
            }

            // Destroy all hands with defunct IDs.
            for (int i = 0; i < ids_to_check.Count; ++i)
            {
                DestroyHand(all_hands [ids_to_check [i]]);
                all_hands.Remove(ids_to_check [i]);
            }
        }
    }