當我在問題中輸入時,我想從可用的座標中繪製骨架線(或繪製兩點之間的線)。繪製完成後,完成的手動骨架將如下所示。它和Skeleton Basic一樣繪製,但是我們提供的座標。如何從可用座標中繪製骨架?
http://social.msdn.microsoft.com/Forums/getfile/425774
我保存關節的座標中的一個文本文件,該應用程序會從這個文件中的數據來繪製。誰能幫幫我嗎 ?我真的需要它。
我這樣做,但屏幕上的骨架被凍結,它沒有按照文本文件的座標移動。
FileStream fs;
private void Model_DrawBoneAndJoints(ref Skeleton skeleton, DrawingContext drawingContext)
{
fs = new FileStream
(@"C:\Users\PhucTruongTien\Desktop\datagram.txt", FileMode.Open, FileAccess.Read, FileShare.None);
StreamReader sr = new StreamReader(fs);
float[] x = new float[20];
float[] y = new float[20];
SkeletonPoint position;
Array Joint_Types = Enum.GetValues(typeof(JointType));
//Joint[] joint_array = new Joint[20];
foreach (JointType j_types in Joint_Types)
{
Joint joint = new Joint();
joint = skeleton.Joints[j_types];
joint.TrackingState = JointTrackingState.Tracked;
position = joint.Position;
position.X = (float)Convert.ToDouble(sr.ReadLine());
position.Y = (float)Convert.ToDouble(sr.ReadLine());
position.Z = (float)Convert.ToDouble(sr.ReadLine());
joint.Position = position;
skeleton.Joints[j_types] = joint;
}
}
私人無效DrawBonesAndJoints(骨架骨架,的DrawingContext的DrawingContext) { Model_DrawBoneAndJoints(參照骨架,的DrawingContext);
//i++;
// Render Torso
this.DrawBone(skeleton, drawingContext, JointType.Head, JointType.ShoulderCenter);
this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderLeft);
this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.ShoulderRight);
this.DrawBone(skeleton, drawingContext, JointType.ShoulderCenter, JointType.Spine);
this.DrawBone(skeleton, drawingContext, JointType.Spine, JointType.HipCenter);
this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipLeft);
this.DrawBone(skeleton, drawingContext, JointType.HipCenter, JointType.HipRight);
// Left Arm
this.DrawBone(skeleton, drawingContext, JointType.ShoulderLeft, JointType.ElbowLeft);
this.DrawBone(skeleton, drawingContext, JointType.ElbowLeft, JointType.WristLeft);
this.DrawBone(skeleton, drawingContext, JointType.WristLeft, JointType.HandLeft);
// Right Arm
this.DrawBone(skeleton, drawingContext, JointType.ShoulderRight, JointType.ElbowRight);
this.DrawBone(skeleton, drawingContext, JointType.ElbowRight, JointType.WristRight);
this.DrawBone(skeleton, drawingContext, JointType.WristRight, JointType.HandRight);
// Left Leg
this.DrawBone(skeleton, drawingContext, JointType.HipLeft, JointType.KneeLeft);
this.DrawBone(skeleton, drawingContext, JointType.KneeLeft, JointType.AnkleLeft);
this.DrawBone(skeleton, drawingContext, JointType.AnkleLeft, JointType.FootLeft);
// Right Leg
this.DrawBone(skeleton, drawingContext, JointType.HipRight, JointType.KneeRight);
this.DrawBone(skeleton, drawingContext, JointType.KneeRight, JointType.AnkleRight);
this.DrawBone(skeleton, drawingContext, JointType.AnkleRight, JointType.FootRight);
// Render Joints
foreach (Joint joint in skeleton.Joints)
{
Brush drawBrush = null;
if (joint.TrackingState == JointTrackingState.Tracked)
{
drawBrush = this.trackedJointBrush;
}
else if (joint.TrackingState == JointTrackingState.Inferred)
{
drawBrush = this.inferredJointBrush;
}
if (drawBrush != null)
{
drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(joint.Position), JointThickness, JointThickness);
}
}
}
對不起,我的英語不好!
當你總是讀取具有相同座標的單個骨架的文件時,應該產生什麼動作? –