Exemple #1
0
 private void UpdateHand(InputDevice handDevice, HandProxy handProxy)
 {
     UpdatePalm(handDevice, handProxy);
     //UpdateHandJoint(handDevice, handProxy, "BoneThumbMetacarpal",      handProxy.ThumbMetacarpal);
     UpdateHandJoint(handDevice, handProxy, "BoneThumbProximal", handProxy.ThumbMetacarpal);
     UpdateHandJoint(handDevice, handProxy, "BoneThumbIntermediate", handProxy.ThumbProximal);
     UpdateHandJoint(handDevice, handProxy, "BoneThumbDistal", handProxy.ThumbDistal);
     UpdateHandJoint(handDevice, handProxy, "BoneThumbTip", handProxy.ThumbTip);
     UpdateHandJoint(handDevice, handProxy, "BoneIndexMetacarpal", handProxy.IndexMetacarpal);
     UpdateHandJoint(handDevice, handProxy, "BoneIndexProximal", handProxy.IndexProximal);
     UpdateHandJoint(handDevice, handProxy, "BoneIndexIntermediate", handProxy.IndexIntermediate);
     UpdateHandJoint(handDevice, handProxy, "BoneIndexDistal", handProxy.IndexDistal);
     UpdateHandJoint(handDevice, handProxy, "BoneIndexTip", handProxy.IndexTip);
     UpdateHandJoint(handDevice, handProxy, "BoneMiddleMetacarpal", handProxy.MiddleMetacarpal);
     UpdateHandJoint(handDevice, handProxy, "BoneMiddleProximal", handProxy.MiddleProximal);
     UpdateHandJoint(handDevice, handProxy, "BoneMiddleIntermediate", handProxy.MiddleIntermediate);
     UpdateHandJoint(handDevice, handProxy, "BoneMiddleDistal", handProxy.MiddleDistal);
     UpdateHandJoint(handDevice, handProxy, "BoneMiddleTip", handProxy.MiddleTip);
     UpdateHandJoint(handDevice, handProxy, "BoneRingMetacarpal", handProxy.RingMetacarpal);
     UpdateHandJoint(handDevice, handProxy, "BoneRingProximal", handProxy.RingProximal);
     UpdateHandJoint(handDevice, handProxy, "BoneRingIntermediate", handProxy.RingIntermediate);
     UpdateHandJoint(handDevice, handProxy, "BoneRingDistal", handProxy.RingDistal);
     UpdateHandJoint(handDevice, handProxy, "BoneRingTip", handProxy.RingTip);
     UpdateHandJoint(handDevice, handProxy, "BonePinkyMetacarpal", handProxy.LittleMetacarpal);
     UpdateHandJoint(handDevice, handProxy, "BonePinkyProximal", handProxy.LittleProximal);
     UpdateHandJoint(handDevice, handProxy, "BonePinkyIntermediate", handProxy.LittleIntermediate);
     UpdateHandJoint(handDevice, handProxy, "BonePinkyDistal", handProxy.LittleDistal);
     UpdateHandJoint(handDevice, handProxy, "BonePinkyTip", handProxy.LittleTip);
 }
Exemple #2
0
 private void ApplyTransforms(HandProxy handProxies, JointPose[] jointPoses)
 {
     for (int i = 0; i < jointPoses.Length; i++)
     {
         ApplyPose(handProxies.AllJoints[i], jointPoses[i]);
     }
 }
Exemple #3
0
    private void UpdateHand(XRNode node, HandProxy proxy)
    {
        List <InputDevice> devices = new List <InputDevice>(); // Gosh I hate this API...

        InputDevices.GetDevicesAtXRNode(node, devices);
        if (devices.Count == 1)
        {
            UpdateHand(devices[0], proxy);
        }
    }
Exemple #4
0
 /**
  * MakeHandRepresentation receives a Hand and combines that with an IHandModel to create a HandRepresentation
  * @param hand The Leap Hand data to be drive an IHandModel
  * @param modelType Filters for a type of hand model, for example, physics or graphics hands.
  */
 public override HandRepresentation MakeHandRepresentation(Hand hand, ModelType modelType)
 {
     Chirality handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
       HandRepresentation handRep = new HandProxy(this, hand, handChirality, modelType);
       for (int i = 0; i < ModelPool.Count; i++) {
     ModelGroup group = ModelPool[i];
     if (group.IsEnabled) {
       IHandModel model = group.TryGetModel(handChirality, modelType);
       if (model != null) {
     handRep.AddModel(model);
     modelToHandRepMapping.Add(model, handRep);
       }
     }
       }
       activeHandReps.Add(handRep);
       return handRep;
 }
 /**
  * MakeHandRepresentation receives a Hand and combines that with an IHandModel to create a HandRepresentation
  * @param hand The Leap Hand data to be drive an IHandModel
  * @param modelType Filters for a type of hand model, for example, physics or graphics hands.
  */
 public override HandRepresentation MakeHandRepresentation(Hand hand, ModelType modelType) {
   HandRepresentation handRep = null;
   for (int i = 0; i < ModelPool.Count; i++) {
     IHandModel model = ModelPool[i];
     bool isCorrectHandedness;
     Chirality handChirality = hand.IsRight ? Chirality.Right : Chirality.Left;
     isCorrectHandedness = model.Handedness == handChirality;
     if (!EnforceHandedness || model.Handedness == Chirality.Either) {
       isCorrectHandedness = true;
     }
     bool isCorrectModelType;
     isCorrectModelType = model.HandModelType == modelType;
     if (isCorrectModelType && isCorrectHandedness) {
         ModelPool.RemoveAt(i);
         handRep = new HandProxy(this, model, hand);
         break;
     }
   }
   return handRep;
 }
Exemple #6
0
    private void UpdatePalm(InputDevice handDevice, HandProxy handProxy)
    {
        InputFeatureUsage <Quaternion> rotUsage = new InputFeatureUsage <Quaternion>("DeviceRotation");
        Quaternion handRot;

        if (handDevice.TryGetFeatureValue(rotUsage, out handRot))
        {
            handProxy.Wrist.rotation  = handRot * Reorientation(handProxy);
            handProxy.Wrist.rotation *= Quaternion.Euler(handProxy.WristRotationOffset);
        }

        InputFeatureUsage <Vector3> posUsage = new InputFeatureUsage <Vector3>("DevicePosition");
        Vector3 handPos;

        if (handDevice.TryGetFeatureValue(posUsage, out handPos))
        {
            handProxy.Wrist.position = handPos;
            Vector3 offset = handProxy.Wrist.rotation * handProxy.WristPositionOffset;
            handProxy.Wrist.localPosition += offset;
        }
    }
Exemple #7
0
    private void UpdateHandJoint(InputDevice handDevice, HandProxy hand, string name, Transform proxy)
    {
        if (proxy == null)
        {
            return;
        }

        InputFeatureUsage <Bone> usage = new InputFeatureUsage <Bone>(name);
        Bone bone;

        if (handDevice.TryGetFeatureValue(usage, out bone))
        {
            Vector3 jointPos;
            if (bone.TryGetPosition(out jointPos))
            {
                proxy.position = jointPos;
            }
            Quaternion jointRot;
            if (bone.TryGetRotation(out jointRot))
            {
                proxy.rotation = jointRot * Reorientation(hand);
            }
        }
    }
Exemple #8
0
 private Quaternion Reorientation(HandProxy hand)
 {
     return(Quaternion.Inverse(Quaternion.LookRotation(hand.ModelFingerPointing, -hand.ModelPalmFacing)));
 }
Exemple #9
0
 public void RemoveHandRepresentation(HandProxy handRep) {
   activeHandReps.Remove(handRep);
 }