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()); }
public GhostSkeleton(Skeleton skeleton) : this() { _savedJoints = new List <GhostJoint>(); foreach (Joint joint in skeleton.Joints) { GhostJoint newJoint = new GhostJoint(joint); this.GhostJoints.Add(newJoint); _savedJoints.Add(newJoint); } }
public GhostSkeleton(Skeleton skeleton) : this() { _savedJoints = new List<GhostJoint>(); foreach (Joint joint in skeleton.Joints) { GhostJoint newJoint = new GhostJoint(joint); this.GhostJoints.Add(newJoint); _savedJoints.Add(newJoint); } }
public static GhostJoint operator -(GhostJoint joint0, GhostJoint joint1) { if (joint0.JointType != joint1.JointType) { throw new Exception("Joints must be of the same type to be subtracted"); } GhostJoint newJoint = new GhostJoint(); newJoint.JointType = joint0.JointType; newJoint.X = (joint0.X - joint1.X); newJoint.Y = (joint0.Y - joint1.Y); newJoint.Z = (joint0.Z - joint1.Z); return newJoint; }
public static GhostJoint operator -(GhostJoint joint0, GhostJoint joint1) { if (joint0.JointType != joint1.JointType) { throw new Exception("Joints must be of the same type to be subtracted"); } GhostJoint newJoint = new GhostJoint(); newJoint.JointType = joint0.JointType; newJoint.X = (joint0.X - joint1.X); newJoint.Y = (joint0.Y - joint1.Y); newJoint.Z = (joint0.Z - joint1.Z); return(newJoint); }
private void DrawBone(GhostJoint joint0, GhostJoint joint1, DrawingContext drawingContext, byte alpha) { Pen drawPen = new Pen(new SolidColorBrush(Color.FromArgb(alpha, 0, 0, 0)), 6); Point point0 = this.SkeletonPointToScreen(new SkeletonPoint() { X = joint0.X, Y = joint0.Y, Z = joint0.Z }); Point point1 = this.SkeletonPointToScreen(new SkeletonPoint() { X = joint1.X, Y = joint1.Y, Z = joint1.Z }); int padding = 3; if (point0.X < padding || point0.Y < padding || point0.X + padding > RenderWidth || point0.Y + padding > RenderHeight || point1.X < padding || point1.Y < padding || point1.X + padding > RenderWidth || point1.Y + padding > RenderHeight) { return; } drawingContext.DrawLine(drawPen, point0, point1); }
private void detach_GhostJoints(GhostJoint entity) { this.SendPropertyChanging(); entity.GhostSkeleton = null; }
partial void DeleteGhostJoint(GhostJoint instance);
partial void UpdateGhostJoint(GhostJoint instance);
partial void InsertGhostJoint(GhostJoint instance);
public GhostJoint GetJoint(JointType type) { GhostJoint ghostJoint = this.SavedJoints.SingleOrDefault(joint => joint.JointType == ((int)type)); return(ghostJoint); }