Beispiel #1
0
    //Transform updating methods

    private void updateSpheres()
    {
        if (hand_ != null && hand_.PalmPosition != null)
        {
            //Update all spheres
            List <NetFinger> fingers = hand_.Fingers;
            for (int i = 0; i < fingers.Count; i++)
            {
                NetFinger finger = fingers[i];
                for (int j = 0; j < 4; j++)
                {
                    int key = getFingerJointIndex((int)finger.Type, j);
                    if (key >= 0)
                    {
                        if (_jointSpheres != null && _jointSpheres[key] != null)
                        {
                            Transform sphere = _jointSpheres[key];
                            sphere.localPosition = finger.Bone(j).NextJoint.ToVector3();
                        }
                    }
                }
            }
            palmPositionSphere.localPosition = hand_.PalmPosition.ToVector3();

            Vector3 wristPos = hand_.PalmPosition.ToVector3();
            wristPositionSphere.localPosition = wristPos;

            Transform thumbBase = _jointSpheres[THUMB_BASE_INDEX];

            Vector3 thumbBaseToPalm = thumbBase.localPosition - hand_.PalmPosition.ToVector3();
            mockThumbJointSphere.localPosition = hand_.PalmPosition.ToVector3() + Vector3.Reflect(thumbBaseToPalm, hand_.XBasis.ToVector3());
        }
    }
Beispiel #2
0
    public static NetFinger Read(BinaryReader r)
    {
        NetFinger f     = new NetFinger();
        int       count = r.ReadInt32();

        if (count > 0)
        {
            f.bones = new NetBone[count];
            for (int i = 0; i < f.bones.Length; i++)
            {
                f.bones[i] = NetBone.Read(r);
            }
        }
        f.Type = r.ReadInt32();
        return(f);
    }
Beispiel #3
0
 public static void Write(BinaryWriter w, NetFinger f)
 {
     if (f.bones == null || f.bones.Length == 0)
     {
         w.Write(0);
     }
     else
     {
         w.Write(f.bones.Length);
         for (int i = 0; i < f.bones.Length; i++)
         {
             NetBone.Write(w, f.bones[i]);
         }
     }
     w.Write(f.Type);
 }
Beispiel #4
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);
 }
Beispiel #5
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);
    }
Beispiel #6
0
    //Geometry creation methods

    private void createSpheres()
    {
        //Create spheres for finger joints
        List <NetFinger> fingers = hand_.Fingers;

        for (int i = 0; i < fingers.Count; i++)
        {
            NetFinger finger = fingers[i];
            for (int j = 0; j < 4; j++)
            {
                int key = getFingerJointIndex((int)finger.Type, j);
                if (key >= 0)
                {
                    _jointSpheres[key] = createSphere("Joint", SPHERE_RADIUS);
                }
            }
        }

        mockThumbJointSphere = createSphere("MockJoint", SPHERE_RADIUS);
        palmPositionSphere   = createSphere("PalmPosition", PALM_RADIUS);
        wristPositionSphere  = createSphere("WristPosition", SPHERE_RADIUS);
    }