用的是kinect,捕捉到人,将人手的point加入到id中,用tuioServer模拟器,模拟多点触摸.tuioServer是保存id中的位置,比如记录下你的左手id为1,那么在你左手不消失前,id不变,id中的point在改变,只要不断update里面id的point即可.下面为关键代码,引用了TuioServer
//过期的点 var delPoints = pointableIDs.Where(pointableID => NowPointIDs.All(m => m != pointableID)).ToList(); //循环删除过期的点 foreach (var pointableID in delPoints) { tuioServer.DeleteTuioCursor(pointableID); pointableIDs.Remove(pointableID); } //更新 tuioServer.CommitFrame(); //每次遍历完后,添加这次获取到的id值,清空原来的值 NowPointIDs = new List<int>(); if (skeletonFrame != null) { //linq语法,查找离kinect最近的,被跟踪的骨骼 skeletonFrame.CopySkeletonDataTo(frameSkeletons); var currentSkeletons = (from s in frameSkeletons where s.TrackingState == SkeletonTrackingState.Tracked && s.Joints[JointType.Head].TrackingState == JointTrackingState.Tracked //select s).OrderBy(s => s.Joints[JointType.Head].Position.Z).FirstOrDefault(); select s).Take(MaxSkeletonTrackingCount).ToList(); if (currentSkeletons.Any()) { //将点添加到list集合 for (var k = 0; k < currentSkeletons.Count(); k++) { //只获取到一只手?? HandsPoint[2 * k] = GetJointPoint(currentSkeletons[k].Joints[JointType.HandRight]); NowPointIDs.Add(2 * k); HandsPoint[1 + 2 * k] = GetJointPoint(currentSkeletons[k].Joints[JointType.HandLeft]); NowPointIDs.Add(1 + 2 * k); Title = HandsPoint[2 * k].ToString() + HandsPoint[1 + 2 * k].ToString(); if (pointableIDs.Any(m => m == 2 * k)) { tuioServer.UpdateTuioCursor(2 * k, new PointF((float)HandsPoint[2 * k].X, (float)HandsPoint[2 * k].Y)); } else { pointableIDs.Add(2 * k); tuioServer.AddTuioCursor(2 * k, new PointF((float)HandsPoint[2 * k].X, (float)HandsPoint[2 * k].Y)); } if (pointableIDs.Any(m => m == 1 + 2 * k)) { tuioServer.UpdateTuioCursor(1 + 2 * k, new PointF((float)HandsPoint[1 + 2 * k].X, (float)HandsPoint[1 + 2 * k].Y)); } else { pointableIDs.Add(1 + 2 * k); tuioServer.AddTuioCursor(1 + 2 * k, new PointF((float)HandsPoint[1 + 2 * k].X, (float)HandsPoint[1 + 2 * k].Y)); } } } }