示例#1
0
 public void UpdateBonePosition(Microsoft.Kinect.JointCollection joints, JointType j1, JointType j2)
 {
     var seg = new Segment(
         (joints[j1].Position.X * this.playerScale) + this.playerCenter.X,
         this.playerCenter.Y - (joints[j1].Position.Y * this.playerScale),
         (joints[j2].Position.X * this.playerScale) + this.playerCenter.X,
         this.playerCenter.Y - (joints[j2].Position.Y * this.playerScale)) { Radius = Math.Max(3.0, this.playerBounds.Height * BoneSize) / 2 };
     this.UpdateSegmentPosition(j1, j2, seg);
 }
示例#2
0
 public void UpdateJointPosition(Microsoft.Kinect.JointCollection joints, JointType j)
 {
     var seg = new Segment(
         (joints[j].Position.X * this.playerScale) + this.playerCenter.X,
         this.playerCenter.Y - (joints[j].Position.Y * this.playerScale)) { Radius = this.playerBounds.Height * ((j == JointType.Head) ? HeadSize : HandSize) / 2 };
     this.UpdateSegmentPosition(j, j, seg);
 }
示例#3
0
        // Update the segment's position and compute a smoothed velocity for the circle or the
        // endpoints of the segment based on  the time it took it to move from the last position
        // to the current one.  The velocity is in pixels per second.
        public void UpdateSegment(Segment s)
        {
            this.LastSegment = this.Segment;
            this.Segment = s;

            DateTime cur = DateTime.Now;
            double fMs = cur.Subtract(this.TimeLastUpdated).TotalMilliseconds;
            if (fMs < 10.0)
            {
                fMs = 10.0;
            }

            double fps = 1000.0 / fMs;
            this.TimeLastUpdated = cur;

            if (this.Segment.IsCircle())
            {
                this.XVelocity = (this.XVelocity * Smoothing) + ((1.0 - Smoothing) * (this.Segment.X1 - this.LastSegment.X1) * fps);
                this.YVelocity = (this.YVelocity * Smoothing) + ((1.0 - Smoothing) * (this.Segment.Y1 - this.LastSegment.Y1) * fps);
            }
            else
            {
                this.XVelocity = (this.XVelocity * Smoothing) + ((1.0 - Smoothing) * (this.Segment.X1 - this.LastSegment.X1) * fps);
                this.YVelocity = (this.YVelocity * Smoothing) + ((1.0 - Smoothing) * (this.Segment.Y1 - this.LastSegment.Y1) * fps);
                this.XVelocity2 = (this.XVelocity2 * Smoothing) + ((1.0 - Smoothing) * (this.Segment.X2 - this.LastSegment.X2) * fps);
                this.YVelocity2 = (this.YVelocity2 * Smoothing) + ((1.0 - Smoothing) * (this.Segment.Y2 - this.LastSegment.Y2) * fps);
            }
        }
示例#4
0
 private void UpdateSegmentPosition(JointType j1, JointType j2, Segment seg)
 {
     var bone = new Bone(j1, j2);
     if (this.segments.ContainsKey(bone))
     {
         BoneData data = this.segments[bone];
         data.UpdateSegment(seg);
         this.segments[bone] = data;
     }
     else
     {
         this.segments.Add(bone, new BoneData(seg));
     }
 }
示例#5
0
 public BoneData(Segment s)
 {
     this.Segment = this.LastSegment = s;
     this.XVelocity = this.YVelocity = 0;
     this.XVelocity2 = this.YVelocity2 = 0;
     this.TimeLastUpdated = DateTime.Now;
 }