Exemplo n.º 1
0
        public void UpdateCache(int interpolationFactor = 0)
        {
            for (int i = 0; i < this.GhostSkeletons.Count - 1; i += (interpolationFactor + 1))
            {
                GhostSkeleton current = this.GhostSkeletons[i];
                GhostSkeleton next    = this.GhostSkeletons[i + 1];

                List <GhostSkeleton> newSkeletons = new List <GhostSkeleton>();
                for (int j = 0; j < interpolationFactor; j++)
                {
                    GhostSkeleton newSkeleton = new GhostSkeleton();
                    this.GhostSkeletons.Insert(i + j + 1, newSkeleton);
                    newSkeletons.Add(newSkeleton);
                }

                foreach (GhostJoint joint in current.GhostJoints)
                {
                    GhostJoint nextJoint = next.GetJoint((JointType)joint.JointType);
                    if (nextJoint == null)
                    {
                        continue;
                    }

                    GhostJoint deltaJoint = (nextJoint - joint) / (interpolationFactor + 1);
                    for (int j = 0; j < interpolationFactor; j++)
                    {
                        GhostJoint newJoint = joint + (deltaJoint * (j + 1));
                        newSkeletons[j].GhostJoints.Add(newJoint);
                    }
                }
            }

            this.SavedSkeletons = this.GhostSkeletons.ToList();
            this.SavedSkeletons.ForEach(skel => skel.UpdateCache());
        }
Exemplo n.º 2
0
        private void DrawBonesAndJoints(GhostSkeleton skeleton, DrawingContext drawingContext)
        {
            byte alpha = 100;

            // Render Torso
            this.DrawBone(skeleton.GetJoint(JointType.Head), skeleton.GetJoint(JointType.ShoulderCenter), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderCenter), skeleton.GetJoint(JointType.ShoulderLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderCenter), skeleton.GetJoint(JointType.ShoulderRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderCenter), skeleton.GetJoint(JointType.Spine), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.Spine), skeleton.GetJoint(JointType.HipCenter), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.HipCenter), skeleton.GetJoint(JointType.HipLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.HipCenter), skeleton.GetJoint(JointType.HipRight), drawingContext, alpha);

            // Left Arm
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderLeft), skeleton.GetJoint(JointType.ElbowLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ElbowLeft), skeleton.GetJoint(JointType.WristLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.WristLeft), skeleton.GetJoint(JointType.HandLeft), drawingContext, alpha);

            // Right Arm
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderRight), skeleton.GetJoint(JointType.ElbowRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ElbowRight), skeleton.GetJoint(JointType.WristRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.WristRight), skeleton.GetJoint(JointType.HandRight), drawingContext, alpha);

            // Left Leg
            this.DrawBone(skeleton.GetJoint(JointType.HipLeft), skeleton.GetJoint(JointType.KneeLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.KneeLeft), skeleton.GetJoint(JointType.AnkleLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.AnkleLeft), skeleton.GetJoint(JointType.FootLeft), drawingContext, alpha);

            // Right Leg
            this.DrawBone(skeleton.GetJoint(JointType.HipRight), skeleton.GetJoint(JointType.KneeRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.KneeRight), skeleton.GetJoint(JointType.AnkleRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.AnkleRight), skeleton.GetJoint(JointType.FootRight), drawingContext, alpha);
        }
Exemplo n.º 3
0
        private void DrawBonesAndJoints(GhostSkeleton skeleton, DrawingContext drawingContext)
        {
            byte alpha = 100;

            // Render Torso
            this.DrawBone(skeleton.GetJoint(JointType.Head), skeleton.GetJoint(JointType.ShoulderCenter), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderCenter), skeleton.GetJoint(JointType.ShoulderLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderCenter), skeleton.GetJoint(JointType.ShoulderRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderCenter), skeleton.GetJoint(JointType.Spine), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.Spine), skeleton.GetJoint(JointType.HipCenter), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.HipCenter), skeleton.GetJoint(JointType.HipLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.HipCenter), skeleton.GetJoint(JointType.HipRight), drawingContext, alpha);

            // Left Arm
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderLeft), skeleton.GetJoint(JointType.ElbowLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ElbowLeft), skeleton.GetJoint(JointType.WristLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.WristLeft), skeleton.GetJoint(JointType.HandLeft), drawingContext, alpha);

            // Right Arm
            this.DrawBone(skeleton.GetJoint(JointType.ShoulderRight), skeleton.GetJoint(JointType.ElbowRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.ElbowRight), skeleton.GetJoint(JointType.WristRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.WristRight), skeleton.GetJoint(JointType.HandRight), drawingContext, alpha);

            // Left Leg
            this.DrawBone(skeleton.GetJoint(JointType.HipLeft), skeleton.GetJoint(JointType.KneeLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.KneeLeft), skeleton.GetJoint(JointType.AnkleLeft), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.AnkleLeft), skeleton.GetJoint(JointType.FootLeft), drawingContext, alpha);

            // Right Leg
            this.DrawBone(skeleton.GetJoint(JointType.HipRight), skeleton.GetJoint(JointType.KneeRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.KneeRight), skeleton.GetJoint(JointType.AnkleRight), drawingContext, alpha);
            this.DrawBone(skeleton.GetJoint(JointType.AnkleRight), skeleton.GetJoint(JointType.FootRight), drawingContext, alpha);
        }