Exemple #1
0
 private void send()
 {
     while (connected)
     {
         if (skeletons > 0)
         {
             try {
                 receiver.Send("/torso_trackjointpos 1");
                 Debug.Log("sent, sleeping...");
                 Thread.Sleep(1000);
             } catch (Exception e) {
                 Debug.Log(e.Message);
                 Console.WriteLine(e.Message);
             }
         }
     }
 }
    private void SendLeapData()
    {
        ArrayList output = new ArrayList();
        Frame     frame  = controller.Frame();
        Hand      left   = null;
        Hand      right  = null;

        foreach (Hand h in frame.Hands)
        {
            if (h.IsLeft)
            {
                left = h;
            }
            else
            {
                right = h;
            }
        }

        //Left
        if (left == null)
        {
            for (int i = 0; i < 12; i++)
            {
                output.Add(0);
            }
        }
        else
        {
            //Palm data
            output.Add(left.PalmNormal.Roll * 100);
            output.Add(left.PalmNormal.Pitch * 100);
            output.Add(left.PalmNormal.Yaw * 100);
            output.Add(left.GrabAngle * 100);
            output.Add(left.PalmVelocity.x);
            output.Add(left.PalmVelocity.y);
            output.Add(left.PalmVelocity.z);

            //Fingers
            List <Finger> fingers = left.Fingers;
            for (int i = 0; i < 5; i++)
            {
                float fingerAngle = Vector3.Angle(left.Direction.ToVector3(), fingers[i].Direction.ToVector3());
                output.Add(fingerAngle * 2);
            }
        }

        if (oscReceiverLeft != null && left != null)
        {
            oscReceiverLeft.Send(output);
        }

        output = new ArrayList();

        //Right
        if (right == null)
        {
            for (int i = 0; i < 12; i++)
            {
                output.Add(0);
            }
        }
        else
        {
            //Palm data
            output.Add(right.PalmNormal.Roll * 100);
            output.Add(right.PalmNormal.Pitch * 100);
            output.Add(right.PalmNormal.Yaw * 100);
            output.Add(right.GrabAngle * 100);
            output.Add(right.PalmVelocity.x);
            output.Add(right.PalmVelocity.y);
            output.Add(right.PalmVelocity.z);

            //Fingers
            List <Finger> fingers = right.Fingers;
            for (int i = 0; i < 5; i++)
            {
                float fingerAngle = Vector3.Angle(right.Direction.ToVector3(), fingers[i].Direction.ToVector3());
                output.Add(fingerAngle * 2);
            }
        }

        if (oscReceiverRight != null && right != null)
        {
            oscReceiverRight.Send(output);
        }
    }