예제 #1
0
 public void BeginHand(byte[] arrHand)
 {
     Enable = true;
     hand_  = LeapHandData.Deserialize(arrHand);
     InitHand();
     BeginHand();
     UpdateHand();
 }
예제 #2
0
 void Update()
 {
     hand = handModel.GetLeapHand();
     if (hand != null)
     {
         transform.localPosition = hand.PalmPosition.ToVector3();
         transform.localRotation = hand.Rotation.ToQuaternion();
     }
 }
예제 #3
0
 void Start()
 {
     hand = handModel.GetLeapHand();
     if (hand != null)
     {
         transform.localPosition = hand.PalmPosition.ToVector3();
         transform.localRotation = hand.Rotation.ToQuaternion();
         transform.localScale    = new Vector3(1f, 1f, 1f);
     }
 }
예제 #4
0
    public static byte[] Serialize(Hand hand)
    {
        if (hand == null)
        {
            return(null);
        }

        NetHand nethand = new NetHand(hand);

        return(Serialize(nethand));
    }
예제 #5
0
 // Convert a byte array to an Object
 public static NetHand Deserialize(byte[] arr)
 {
     if (arr == null)
     {
         return(null);
     }
     using (MemoryStream stream = new MemoryStream(arr))
     {
         using (BinaryReader reader = new BinaryReader(stream))
         {
             return(NetHand.Read(reader));
         }
     }
 }
예제 #6
0
 public void SetLeapHand(byte[] arrHand)
 {
     if (hand_ == null)
     {
         hand_ = LeapHandData.Deserialize(arrHand);
         InitHand();
         BeginHand();
         UpdateHand();
     }
     else
     {
         hand_ = LeapHandData.Deserialize(arrHand);
         UpdateHand();
     }
 }
예제 #7
0
 public static void Write(BinaryWriter w, NetHand h)
 {
     if (h.Fingers == null || h.Fingers.Count == 0)
     {
         w.Write(0);
     }
     else
     {
         w.Write(h.Fingers.Count);
         foreach (NetFinger f in h.Fingers)
         {
             NetFinger.Write(w, f);
         }
     }
     w.Write(h.IsLeft);
     NetVector.Write(w, h.PalmPosition);
     NetVector.Write(w, h.XBasis);
 }
예제 #8
0
    public static NetHand Read(BinaryReader r)
    {
        NetHand h     = new NetHand();
        int     count = r.ReadInt32();

        h.Fingers = new List <NetFinger>();
        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                NetFinger f = NetFinger.Read(r);
                h.Fingers.Add(f);
            }
        }
        h.IsLeft       = r.ReadBoolean();
        h.PalmPosition = NetVector.Read(r);
        h.XBasis       = NetVector.Read(r);

        return(h);
    }
예제 #9
0
    public static byte[] Serialize(NetHand hand)
    {
        if (hand == null)
        {
            return(null);
        }

        byte[] data = null;
        using (MemoryStream stream = new MemoryStream())
        {
            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                NetHand.Write(writer, hand);

                stream.Position = 0;
                data            = new byte[stream.Length];
                stream.Read(data, 0, data.Length);
            }
        }
        return(data);
    }
예제 #10
0
 public void FinishHand()
 {
     isTracked = false;
     hand_     = null;
     Enable    = false;
 }
예제 #11
0
 public void SetLeapHand(byte[] arrHand)
 {
     hand_ = LeapHandData.Deserialize(arrHand);
     UpdateHand();
 }