/// <summary> /// /// </summary> /// <param name="user"></param> /// <param name="joint"></param> /// <param name="jointRef"></param> /// <param name="screenPlaneZoffset"></param> /// <returns>true if touched </returns> private void DetectVirtualRelativeTouch(User user, uint hand, SkeletonJoint jointRef, int screenPlaneZoffset) { SkeletonJoint jointHand; if (hand == 0) { jointHand = SkeletonJoint.LeftHand; } else { jointHand = SkeletonJoint.RightHand; } Point3D pos = user.Joints[jointHand].Position; Point3D posRef = user.Joints[jointRef].Position; InputStatus status; //hand not probably tracked return if (user.Joints[jointHand].Confidence < 0.6) { sendContact(user.updateHand(hand, InputStatus.UNKNOWN)); return; } //if the reference is not valid, only cursor mode will be reliable else if (user.Joints[jointRef].Confidence < 0.6) { status = InputStatus.CURSOR; } else { //both joints are well tracked, touch detection is executed if (pos.Z > (posRef.Z - screenPlaneZoffset)) {//No Touch status = InputStatus.CURSOR; } else {//Touch status = InputStatus.TOUCHED; } } //convert kinectcoordinates to screencoordinates pos.X = virtualScreenXStart + virtualScreenConvertFactorX * (pos.X - kinectXCrop); pos.Y = virtualScreenYStart + virtualScreenConvertFactorY * (pos.Y - kinectYCrop); HandContact contact = user.updateHand(pos, hand, status); sendContact(contact); }
private void DetectVirtualAbsoluteTouch(User user, uint hand, int screenPlaneZoffset) { SkeletonJoint jointHand; if (hand == 0) { jointHand = SkeletonJoint.LeftHand; } else { jointHand = SkeletonJoint.RightHand; } Point3D pos = user.Joints[jointHand].Position; InputStatus status; //hand not probably tracked return if (user.Joints[jointHand].Confidence < 0.6) { sendContact(user.updateHand(hand, InputStatus.UNKNOWN)); return; } else { //both joints are well tracked, touch detection is executed if (pos.Z > screenPlaneZoffset) {//No Touch status = InputStatus.CURSOR; } else {//Touch status = InputStatus.TOUCHED; } } //convert kinectcoordinates to screencoordinates pos.X = virtualScreenXStart + virtualScreenConvertFactorX * (pos.X - kinectXCrop); pos.Y = virtualScreenYStart + virtualScreenConvertFactorY * (pos.Y - kinectYCrop); HandContact contact = user.updateHand(pos, hand, status); if (contact != null) { inputProvider.EnqueueContact(contact); } }