Ejemplo n.º 1
0
 void Update()
 {
     if (rigid_hand_.GetLeapHand().IsRight)
     {
         HandMoveCheck();
     }
 }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (manoDestra.IsTracked && manoSinistra.IsTracked)
        {
            Hand    r = manoDestra.GetLeapHand(), l = manoSinistra.GetLeapHand();
            Vector3 rn = manoDestra.GetPalmNormal(), rd = manoDestra.GetPalmDirection(), ln = manoSinistra.GetPalmNormal(), ld = manoSinistra.GetPalmDirection();

            if (r.GrabAngle >= grabAngleMin && r.GrabAngle <= grabAngleMax && l.GrabAngle >= grabAngleMin && l.GrabAngle <= grabAngleMax && rn.z / ln.z < 0 && rd.x < 0 && ld.x > 0)
            {
                BroadcastMessage("InZoom", true);
                Camera.main.fieldOfView = (Distanza() - offset);
            }
            else if (r.GrabStrength == 0 && l.GrabStrength == 0 && rn.z < 0 && ln.z < 0 && rd.y > 0 && ld.y > 0)
            {
                BroadcastMessage("InZoom", true);
                Camera.main.fieldOfView = Distanza1() - offset1;
            }
            else
            {
                offset  = Distanza() - Camera.main.fieldOfView;
                offset1 = Distanza1() - Camera.main.fieldOfView;
                BroadcastMessage("InZoom", false);
            }
        }
    }
    void LeftOrRightHandCheck()
    {
        if (rigid_hand_.GetLeapHand().IsLeft)
        {
            left_hand_move_checker_  = GetComponent <LeftHandMoveChecker>();
            right_hand_move_checker_ = GetComponent <RightHandMoveChecker>();

            left_hand_move_checker_.enabled  = true;
            right_hand_move_checker_.enabled = false;
        }
        else
        if (rigid_hand_.GetLeapHand().IsRight)
        {
            left_hand_move_checker_  = GetComponent <LeftHandMoveChecker>();
            right_hand_move_checker_ = GetComponent <RightHandMoveChecker>();

            left_hand_move_checker_.enabled  = false;
            right_hand_move_checker_.enabled = true;
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        Controller c = new Controller();

        if (mano.IsTracked)
        {
            Hand h = mano.GetLeapHand();

            for (int i = 0; i < comandi.Length; i++)
            {
                comandi[i].SetActive(h.GrabStrength >= 0 && h.GrabStrength <= 0.1 && mano.GetPalmNormal().z < 0 && mano.GetPalmDirection().y > 0);
            }
        }
    }
Ejemplo n.º 5
0
    void Start()
    {
        max_hand_distance_ = 1;
        rigid_hand_        = GetComponent <RigidHand>();
        hand_controller_   = FindObjectOfType <HandController>();
        is_hand_exist_     = GetComponentInParent <IsHandExist>();

        hand_pos_ = rigid_hand_.GetPalmPosition();
        if (rigid_hand_.GetLeapHand().IsRight)
        {
            hand_old_pos_ = right_hand_pos_zero_;
        }

        once_position_unification_ = false;
        distance_difference_       = new Vector3(0.0f, 0.0f, 0.0f);
    }
    void Start()
    {
        max_hand_distance_ = 1;
        rigid_hand_ = GetComponent<RigidHand>();
        hand_controller_ = FindObjectOfType<HandController>();
        is_hand_exist_ = GetComponentInParent<IsHandExist>();

        hand_pos_ = rigid_hand_.GetPalmPosition();
        if (rigid_hand_.GetLeapHand().IsLeft)
        {
            hand_old_pos_ = left_hand_pos_zero_;
        }

        once_position_unification_ = false;
        distance_difference_ = new Vector3(0.0f, 0.0f, 0.0f);
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (!afferraZoom && manoDestra.IsTracked && manoSinistra.IsTracked)
        {
            if (!spostamento)
            {
                MeshRenderer[] collMesh = FindObjectsOfType <MeshRenderer>();

                foreach (MeshRenderer mr in collMesh)
                {
                    Transform t = mr.transform;

                    if (Utility.TagDaEvitare(t))
                    {
                        Transform padre = Utility.GetPrimoPadre(t);
                        Vector3   dir   = t.position - padre.position;
                        childsDir.Add(t, dir);
                    }
                }

                offset      = (manoDestra.GetPalmPosition() - manoSinistra.GetPalmPosition()).magnitude;
                spostamento = true;
            }

            // Effettuo lo spostamento degli oggetti, controllando se è stato compiuto il giusto gesto (tutte e 2 le mani chiuse a pugno)
            if (spostamento && manoDestra.GetLeapHand().GrabAngle >= 2 && manoSinistra.GetLeapHand().GrabAngle >= 2)
            {
                float distanza = (manoDestra.GetPalmPosition() - manoSinistra.GetPalmPosition()).magnitude;
                Dictionary <Transform, Vector3> posIniziali = InitialPosition.Direzioni;

                foreach (KeyValuePair <Transform, Vector3> obj in childsDir)
                {
                    Vector3 nuovaPosizione = obj.Value * ((distanza - offset) * velocitàSpostamento + 1);

                    // Non permetto di scendere al di sotto del minimo della posizione di partenza, evitando quindi di far collassare tutto al centro.
                    if (nuovaPosizione.IsLongerThan(posIniziali[obj.Key], obj.Value))
                    {
                        obj.Key.position = Utility.GetPrimoPadre(obj.Key).position + nuovaPosizione;
                    }
                }
            }
            else
            {
                Init();
            }
        }
    }