示例#1
0
 public Bone makeBone(ref LEAP_BONE bone, Bone.BoneType type)
 {
     Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
       Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
       Vector center = (nextJoint + prevJoint) * .5f;
       float length = (nextJoint - prevJoint).Magnitude;
       Vector direction = (nextJoint - prevJoint) / length;
       LeapQuaternion rotation = new LeapQuaternion(bone.rotation);
       return new Bone(prevJoint, nextJoint, center, direction, length, bone.width, type, rotation);
 }
        public Bone makeBone(ref LEAP_BONE bone, Bone.BoneType type)
        {
            Vector         prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
            Vector         nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
            Vector         center    = (nextJoint + prevJoint) * .5f;
            float          length    = (nextJoint - prevJoint).Magnitude;
            Vector         direction = (nextJoint - prevJoint) / length;
            LeapQuaternion rotation  = new LeapQuaternion(bone.rotation);

            return(new Bone(prevJoint, nextJoint, center, direction, length, bone.width, type, rotation));
        }
示例#3
0
 public Arm makeArm(ref LEAP_BONE bone)
 {
     Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
       Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
       Vector center = (nextJoint + prevJoint) * .5f;
       float length = (nextJoint - prevJoint).Magnitude;
       Vector direction = Vector.Zero;
       if (length > 0)
     direction = (nextJoint - prevJoint) / length;
       LeapQuaternion rotation = new LeapQuaternion(bone.rotation);
       return new Arm(prevJoint, nextJoint, center, direction, length, bone.width, rotation);
 }
示例#4
0
        public Hand makeHand(ref LEAP_HAND hand, Frame owningFrame)
        {
            LEAP_BONE arm = StructMarshal <LEAP_BONE> .PtrToStruct(hand.arm);

            Arm       newArm = makeArm(ref arm);
            LEAP_PALM palm   = StructMarshal <LEAP_PALM> .PtrToStruct(hand.palm);

            Hand newHand = new Hand(
                (int)owningFrame.Id,
                (int)hand.id,
                hand.confidence,
                hand.grab_strength,
                hand.grab_angle,
                hand.pinch_strength,
                hand.pinch_distance,
                palm.width,
                hand.type == eLeapHandType.eLeapHandType_Left,
                hand.visible_time,
                newArm,
                new List <Finger>(5),
                new Vector(palm.position.x, palm.position.y, palm.position.z),
                new Vector(palm.stabilized_position.x, palm.stabilized_position.y, palm.stabilized_position.z),
                new Vector(palm.velocity.x, palm.velocity.y, palm.velocity.z),
                new Vector(palm.normal.x, palm.normal.y, palm.normal.z),
                new Vector(palm.direction.x, palm.direction.y, palm.direction.z),
                newArm.NextJoint //wrist position
                );
            LEAP_DIGIT thumbDigit = StructMarshal <LEAP_DIGIT> .PtrToStruct(hand.thumb);

            newHand.Fingers.Insert(0, makeFinger(owningFrame, ref hand, ref thumbDigit, Finger.FingerType.TYPE_THUMB));

            LEAP_DIGIT indexDigit = StructMarshal <LEAP_DIGIT> .PtrToStruct(hand.index);

            newHand.Fingers.Insert(1, makeFinger(owningFrame, ref hand, ref indexDigit, Finger.FingerType.TYPE_INDEX));

            LEAP_DIGIT middleDigit = StructMarshal <LEAP_DIGIT> .PtrToStruct(hand.middle);

            newHand.Fingers.Insert(2, makeFinger(owningFrame, ref hand, ref middleDigit, Finger.FingerType.TYPE_MIDDLE));

            LEAP_DIGIT ringDigit = StructMarshal <LEAP_DIGIT> .PtrToStruct(hand.ring);

            newHand.Fingers.Insert(3, makeFinger(owningFrame, ref hand, ref ringDigit, Finger.FingerType.TYPE_RING));

            LEAP_DIGIT pinkyDigit = StructMarshal <LEAP_DIGIT> .PtrToStruct(hand.pinky);

            newHand.Fingers.Insert(4, makeFinger(owningFrame, ref hand, ref pinkyDigit, Finger.FingerType.TYPE_PINKY));

            return(newHand);
        }
        public Arm makeArm(ref LEAP_BONE bone)
        {
            Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
            Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
            Vector center    = (nextJoint + prevJoint) * .5f;
            float  length    = (nextJoint - prevJoint).Magnitude;
            Vector direction = Vector.Zero;

            if (length > 0)
            {
                direction = (nextJoint - prevJoint) / length;
            }
            LeapQuaternion rotation = new LeapQuaternion(bone.rotation);

            return(new Arm(prevJoint, nextJoint, center, direction, length, bone.width, rotation));
        }
示例#6
0
    /**
     * Copies the data from an internal bone definition into a bone.
     *
     * @param leapBone The internal bone definition to be copied into this bone.
     * @param type The bone type of this bone.
     */
    public static Bone CopyFrom(this Bone bone, LEAP_BONE leapBone, Bone.BoneType type) {
      bone.Type = type;
      bone.PrevJoint = leapBone.prev_joint.ToLeapVector();
      bone.NextJoint = leapBone.next_joint.ToLeapVector();
      bone.Direction = (bone.NextJoint - bone.PrevJoint);
      bone.Length = bone.Direction.Magnitude;

      if (bone.Length < float.Epsilon) {
        bone.Direction = Vector.Zero;
      } else {
        bone.Direction /= bone.Length;
      }

      bone.Center = (bone.PrevJoint + bone.NextJoint) / 2.0f;
      bone.Rotation = leapBone.rotation.ToLeapQuaternion();
      bone.Width = leapBone.width;

      return bone;
    }
        public Bone makeBone(ref LEAP_BONE bone, Bone.BoneType type)
        {
            Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
            Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
            Vector center    = (nextJoint + prevJoint) * .5f;
            float  length    = (nextJoint - prevJoint).Magnitude;
            Vector direction = (nextJoint - prevJoint) / length;
            Matrix basis     = new Matrix(bone.basis.x_basis.x,
                                          bone.basis.x_basis.y,
                                          bone.basis.x_basis.z,
                                          bone.basis.y_basis.x,
                                          bone.basis.y_basis.y,
                                          bone.basis.y_basis.z,
                                          bone.basis.z_basis.x,
                                          bone.basis.z_basis.y,
                                          bone.basis.z_basis.z);

            return(new Bone(prevJoint, nextJoint, center, direction, length, bone.width, type, basis));
        }
        public Arm makeArm(ref LEAP_BONE bone)
        {
            Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
            Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
            Vector center    = (nextJoint + prevJoint) * .5f;
            float  length    = (nextJoint - prevJoint).Magnitude;
            Vector direction = Vector.Zero;

            if (length > 0)
            {
                direction = (nextJoint - prevJoint) / length;
            }
            Matrix basis = new Matrix(bone.basis.x_basis.x,
                                      bone.basis.x_basis.y,
                                      bone.basis.x_basis.z,
                                      bone.basis.y_basis.x,
                                      bone.basis.y_basis.y,
                                      bone.basis.y_basis.z,
                                      bone.basis.z_basis.x,
                                      bone.basis.z_basis.y,
                                      bone.basis.z_basis.z);

            return(new Arm(prevJoint, nextJoint, center, direction, length, bone.width, basis));
        }
 public Bone makeBone(ref LEAP_BONE bone, Bone.BoneType type)
 {
   Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
   Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
   Vector center = (nextJoint + prevJoint) * .5f;
   float length = (nextJoint - prevJoint).Magnitude;
   Vector direction = (nextJoint - prevJoint) / length;
   Matrix basis = new Matrix(bone.basis.x_basis.x,
                      bone.basis.x_basis.y,
                      bone.basis.x_basis.z,
                      bone.basis.y_basis.x,
                      bone.basis.y_basis.y,
                      bone.basis.y_basis.z,
                      bone.basis.z_basis.x,
                      bone.basis.z_basis.y,
                      bone.basis.z_basis.z);
   return new Bone(prevJoint, nextJoint, center, direction, length, bone.width, type, basis);
 }
 public Arm makeArm(ref LEAP_BONE bone)
 {
   Vector prevJoint = new Vector(bone.prev_joint.x, bone.prev_joint.y, bone.prev_joint.z);
   Vector nextJoint = new Vector(bone.next_joint.x, bone.next_joint.y, bone.next_joint.z);
   Vector center = (nextJoint + prevJoint) * .5f;
   float length = (nextJoint - prevJoint).Magnitude;
   Vector direction = Vector.Zero;
   if (length > 0)
     direction = (nextJoint - prevJoint) / length;
   Matrix basis = new Matrix(bone.basis.x_basis.x,
                      bone.basis.x_basis.y,
                      bone.basis.x_basis.z,
                      bone.basis.y_basis.x,
                      bone.basis.y_basis.y,
                      bone.basis.y_basis.z,
                      bone.basis.z_basis.x,
                      bone.basis.z_basis.y,
                      bone.basis.z_basis.z);
   return new Arm(prevJoint, nextJoint, center, direction, length, bone.width, basis);
 }
示例#11
0
 public static LEAP_BONE CreateBone(Bone bone) {
   LEAP_BONE leapBone = new LEAP_BONE();
   leapBone.prev_joint = new LEAP_VECTOR(bone.PrevJoint);
   leapBone.next_joint = new LEAP_VECTOR(bone.NextJoint);
   leapBone.width = bone.Width;
   leapBone.rotation = new LEAP_QUATERNION(bone.Rotation);
   return leapBone;
 }