示例#1
0
        public void UpdateSegment(Segment s)
        {
            LastSegment = Segment;
            Segment = s;

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

            double fps = 1000.0 / fMs;
            TimeLastUpdated = cur;

            if (Segment.IsCircle())
            {
                XVelocity = (XVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.X1 - LastSegment.X1) * fps);
                YVelocity = (YVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.Y1 - LastSegment.Y1) * fps);
            }
            else
            {
                XVelocity = (XVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.X1 - LastSegment.X1) * fps);
                YVelocity = (YVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.Y1 - LastSegment.Y1) * fps);
                XVelocity2 = (XVelocity2 * Smoothing) + ((1.0 - Smoothing) * (Segment.X2 - LastSegment.X2) * fps);
                YVelocity2 = (YVelocity2 * Smoothing) + ((1.0 - Smoothing) * (Segment.Y2 - LastSegment.Y2) * fps);
            }
        }
示例#2
0
 public BoneData(Segment s)
 {
     Segment = LastSegment = s;
     XVelocity = YVelocity = 0;
     XVelocity2 = YVelocity2 = 0;
     TimeLastUpdated = DateTime.Now;
 }
示例#3
0
 public void UpdateJointPosition(JointCollection joints, JointType j)
 {
     var seg = new Segment(
         (joints[j].Position.X * PlayerScale) + PlayerCenter.X,
         PlayerCenter.Y - (joints[j].Position.Y * PlayerScale))
         { Radius = _playerBounds.Height * ((j == JointType.Head) ? HeadSize : HandSize) / 2 };
     UpdateSegmentPosition(j, j, seg);
 }
示例#4
0
 private void UpdateSegmentPosition(JointType j1, JointType j2, Segment seg)
 {
     var bone = new Bone(j1, j2);
     if (_segments.ContainsKey(bone))
     {
         BoneData data = _segments[bone];
         data.UpdateSegment(seg);
         _segments[bone] = data;
     }
     else
     {
         _segments.Add(bone, new BoneData(seg));
     }
 }
示例#5
0
 public void UpdateBonePosition(JointCollection joints, JointType j1, JointType j2)
 {
     var seg = new Segment(
         (joints[j1].Position.X * PlayerScale) + PlayerCenter.X,
         PlayerCenter.Y - (joints[j1].Position.Y * PlayerScale),
         (joints[j2].Position.X * PlayerScale) + PlayerCenter.X,
         PlayerCenter.Y - (joints[j2].Position.Y * PlayerScale))
         { Radius = Math.Max(3.0, _playerBounds.Height * BoneSize) / 2 };
     UpdateSegmentPosition(j1, j2, seg);
 }