Пример #1
0
 // Update is called once per frame
 void Update()
 {
     if (handModel != null)
     {
         if (this.GetComponent <Collider>().bounds.Contains(handModel.GetPalmPosition()))
         {
             if (!handIsSet)
             {
                 ControlHandTracker.getInstance().setControllingHandIsRight(!handModel.GetLeapHand().IsRight);
                 handIsSet = true;
             }
             bool res = Vector3.Cross(handModel.GetLeapHand().PalmNormal.ToVector3(), Vector3.forward).x > 0;
             if (res != facingUp)
             {
                 Debug.Log("palm facing Up : " + res);
                 facingUp = res;
                 MidiController.getInstance().setPalmFacingUp(facingUp);
             }
             bool closed = handModel.GetLeapHand().GrabStrength > 0.6;
             if (closed != handIsClosed)
             {
                 Debug.Log("hand is closed : " + closed);
                 handIsClosed = closed;
                 ControlHandTracker.getInstance().setStaticHandIsClosed(handIsClosed);
             }
         }
         else if (handIsSet)
         {
             handIsSet = false;
             ControlHandTracker.getInstance().stopTracking();
             foreach (MeshRenderer child in gameObject.GetComponentsInChildren <MeshRenderer>())
             {
                 child.material.color = Color.white;
             }
         }
     }
 }
 // Use this for initialiyation
 void Start()
 {
     instance   = this;
     controller = new Controller();
 }