Beispiel #1
0
        private Vertex3 GetJointPosition(Microsoft.Kinect.Skeleton skeleton, JointType jointType)
        {
            Microsoft.Kinect.JointType     kinectJointType = JointUtilities.TranslateJointType(jointType);
            Microsoft.Kinect.SkeletonPoint kinectPoint     = skeleton.Joints[kinectJointType].Position;
            Vertex3 position = GetPosition(kinectPoint);

            return(position);
        }
 public OrientationInfo GetJointInfo(KinectJoint joint, int?playerId = null)
 {
     if (this.thisKinectGesturePlugin == null)
     {
         return(null);
     }
     if (this.thisKinectGesturePlugin.gestureProcessor == null)
     {
         return(null);
     }
     if (this.thisKinectGesturePlugin.gestureProcessor.Skeletons == null)
     {
         return(null);
     }
     Microsoft.Kinect.Skeleton skeleton = null;
     if (playerId == null)
     {
         foreach (Microsoft.Kinect.Skeleton s in this.thisKinectGesturePlugin.gestureProcessor.Skeletons)
         {
             if (s.TrackingState != Microsoft.Kinect.SkeletonTrackingState.NotTracked)
             {
                 skeleton = s; break;
             }
         }
     }
     else
     {
         foreach (Microsoft.Kinect.Skeleton s in this.thisKinectGesturePlugin.gestureProcessor.Skeletons)
         {
             if (s.TrackingId == playerId.Value)
             {
                 skeleton = s; break;
             }
         }
     }
     if (skeleton != null)
     {
         Microsoft.Kinect.SkeletonPoint jointPos = this.thisKinectGesturePlugin.gestureProcessor.NormalizeJoint(skeleton.Joints[(Microsoft.Kinect.JointType)joint]);
         return(new OrientationInfo()
         {
             playerId = skeleton.TrackingId,
             tracked = (skeleton.Joints[(Microsoft.Kinect.JointType)joint].TrackingState != Microsoft.Kinect.JointTrackingState.NotTracked),
             X = jointPos.X,
             Y = jointPos.Y,
             Z = jointPos.Z,
         });
     }
     else
     {
         return(null);
     }
 }
Beispiel #3
0
        private void _HandleSkeletonFrameReady(object sender, Microsoft.Kinect.SkeletonFrameReadyEventArgs args)
        {
            // Capture Kinect data
            Microsoft.Kinect.Skeleton[] skeletons = new Microsoft.Kinect.Skeleton[0];

            using (Microsoft.Kinect.SkeletonFrame kinect_frame = args.OpenSkeletonFrame())
            {
                if (kinect_frame != null)
                {
                    skeletons = new Microsoft.Kinect.Skeleton[kinect_frame.SkeletonArrayLength];
                    kinect_frame.CopySkeletonDataTo(skeletons);
                }
            }

            // Convert the Microsoft Skeleton format to Rhapsody skeletons
            SkeletonFrame frame = new SkeletonFrame();

            foreach (Microsoft.Kinect.Skeleton kinect_skeleton in skeletons)
            {
                if (kinect_skeleton.TrackingState != Microsoft.Kinect.SkeletonTrackingState.Tracked)
                {
                    continue;
                }

                //Console.WriteLine("Kinect found skeleton " + kinect_skeleton.TrackingId + " (" + kinect_skeleton.Position.X + ", " + kinect_skeleton.Position.Y + ")");
                Skeleton skeleton = new Skeleton
                {
                    TrackingState = TrackingState.Tracked
                };

                foreach (Microsoft.Kinect.Joint kinect_joint in kinect_skeleton.Joints)
                {
                    Microsoft.Kinect.SkeletonPoint kinect_point = kinect_joint.Position;
                    skeleton.Joints.Add(JointTypeConverter.Convert(kinect_joint.JointType), new Joint(kinect_point.X, kinect_point.Y, kinect_point.Z));
                }

                frame.Skeletons.Add(skeleton);
            }

            // Invoke each of the Listeners
            foreach (Delegate d in this.SkeletonFrameReady.GetInvocationList())
            {
                d.DynamicInvoke(new object[] { sender, new SkeletonFrameReadyEventArgs {
                                                   Frame = frame
                                               } });
            }
        }
Beispiel #4
0
        public void update(Microsoft.Kinect.SkeletonPoint pt1, Microsoft.Kinect.SkeletonPoint pt2)
        {
            Point3D  diff          = Vector3D.Subtract(new Vector3D(pt1.X, pt1.Y, pt1.Z), new Point3D(pt2.X, pt2.Y, pt2.Z));
            Vector3D differenceVec = new Vector3D(diff.X, diff.Y, -diff.Z);

            this.axis.Axis  = Vector3D.CrossProduct(up, differenceVec);
            this.axis.Angle = -Vector3D.AngleBetween(up, differenceVec);

            this.scale.ScaleX = differenceVec.Length * obesity;
            this.scale.ScaleY = differenceVec.Length;
            this.scale.ScaleZ = differenceVec.Length * obesity;

            this.translation.OffsetZ = pt1.Z;
            this.translation.OffsetX = -pt1.X;
            this.translation.OffsetY = pt1.Y;

            this.rotation.Rotation = axis;
        }
Beispiel #5
0
 public static Vector3 KINECTVectorToXNA(Microsoft.Kinect.SkeletonPoint point)
 {
     return(new Vector3(point.X, point.Y, point.Z));
 }
Beispiel #6
0
 /// <summary>
 /// Determines if the button collides with a specified point
 /// </summary>
 /// <param name="v">The vector to be checked</param>
 /// <returns>true, if there is a collision</returns>
 public abstract bool Collision(NUIVector v);
Beispiel #7
0
 public PointSkeleton3D(Microsoft.Kinect.SkeletonPoint skeltonPoint)
 {
     this.X = skeltonPoint.X;
     this.Y = skeltonPoint.Y;
     this.Z = skeltonPoint.Z;
 }
Beispiel #8
0
 private Vertex3 GetPosition(Microsoft.Kinect.SkeletonPoint kinectPoint)
 {
     return(new Vertex3(kinectPoint.X, kinectPoint.Y, kinectPoint.Z));
 }