public static void AddKinectSkeleton(BVHSkeleton Skeleton) { // The person is the wrong way round in the coordinate system of the Kinect! It is only corrected when saving, so the processing is still with inverted coordinates BVHBone hipCenter = new BVHBone(null, JointType.HipCenter.ToString(), 6, TransAxis.None, true); BVHBone hipCenter2 = new BVHBone(hipCenter, "HipCenter2", 3, TransAxis.Y, false); BVHBone spine = new BVHBone(hipCenter2, JointType.Spine.ToString(), 3, TransAxis.Y, true); BVHBone shoulderCenter = new BVHBone(spine, JointType.ShoulderCenter.ToString(), 3, TransAxis.Y, true); BVHBone collarLeft = new BVHBone(shoulderCenter, "CollarLeft", 3, TransAxis.X, false); BVHBone shoulderLeft = new BVHBone(collarLeft, JointType.ShoulderLeft.ToString(), 3, TransAxis.X, true); BVHBone elbowLeft = new BVHBone(shoulderLeft, JointType.ElbowLeft.ToString(), 3, TransAxis.X, true); BVHBone wristLeft = new BVHBone(elbowLeft, JointType.WristLeft.ToString(), 3, TransAxis.X, true); BVHBone handLeft = new BVHBone(wristLeft, JointType.HandLeft.ToString(), 0, TransAxis.X, true); BVHBone neck = new BVHBone(shoulderCenter, "Neck", 3, TransAxis.Y, false); BVHBone head = new BVHBone(neck, JointType.Head.ToString(), 3, TransAxis.Y, true); BVHBone headtop = new BVHBone(head, "Headtop", 0, TransAxis.None, false); BVHBone collarRight = new BVHBone(shoulderCenter, "CollarRight", 3, TransAxis.nX, false); BVHBone shoulderRight = new BVHBone(collarRight, JointType.ShoulderRight.ToString(), 3, TransAxis.nX, true); BVHBone elbowRight = new BVHBone(shoulderRight, JointType.ElbowRight.ToString(), 3, TransAxis.nX, true); BVHBone wristRight = new BVHBone(elbowRight, JointType.WristRight.ToString(), 3, TransAxis.nX, true); BVHBone handRight = new BVHBone(wristRight, JointType.HandRight.ToString(), 0, TransAxis.nX, true); BVHBone hipLeft = new BVHBone(hipCenter, JointType.HipLeft.ToString(), 3, TransAxis.X, true); BVHBone kneeLeft = new BVHBone(hipLeft, JointType.KneeLeft.ToString(), 3, TransAxis.nY, true); BVHBone ankleLeft = new BVHBone(kneeLeft, JointType.AnkleLeft.ToString(), 3, TransAxis.nY, true); BVHBone footLeft = new BVHBone(ankleLeft, JointType.FootLeft.ToString(), 0, TransAxis.Z, true); BVHBone hipRight = new BVHBone(hipCenter, JointType.HipRight.ToString(), 3, TransAxis.nX, true); BVHBone kneeRight = new BVHBone(hipRight, JointType.KneeRight.ToString(), 3, TransAxis.nY, true); BVHBone ankleRight = new BVHBone(kneeRight, JointType.AnkleRight.ToString(), 3, TransAxis.nY, true); BVHBone footRight = new BVHBone(ankleRight, JointType.FootRight.ToString(), 0, TransAxis.Z, true); Skeleton.AddBone(hipCenter); Skeleton.AddBone(hipCenter2); Skeleton.AddBone(spine); Skeleton.AddBone(shoulderCenter); Skeleton.AddBone(collarLeft); Skeleton.AddBone(shoulderLeft); Skeleton.AddBone(elbowLeft); Skeleton.AddBone(wristLeft); Skeleton.AddBone(handLeft); Skeleton.AddBone(neck); Skeleton.AddBone(head); Skeleton.AddBone(headtop); Skeleton.AddBone(collarRight); Skeleton.AddBone(shoulderRight); Skeleton.AddBone(elbowRight); Skeleton.AddBone(wristRight); Skeleton.AddBone(handRight); Skeleton.AddBone(hipLeft); Skeleton.AddBone(kneeLeft); Skeleton.AddBone(ankleLeft); Skeleton.AddBone(footLeft); Skeleton.AddBone(hipRight); Skeleton.AddBone(kneeRight); Skeleton.AddBone(ankleRight); Skeleton.AddBone(footRight); Skeleton.FinalizeBVHSkeleton(); }
private void WriteEntry() { List <List <BVHBone> > bonesListList = new List <List <BVHBone> >(); List <BVHBone> resultList; while (bvhSkeleton.Bones.Count != 0) { if (bvhSkeletonWritten.Bones.Count == 0) { resultList = bvhSkeleton.Bones.FindAll(i => i.Root == true); bonesListList.Add(resultList); } else { if (bvhSkeletonWritten.Bones.Last().End == false) { for (int k = 1; k <= bvhSkeletonWritten.Bones.Count; k++) { resultList = bvhSkeletonWritten.Bones[bvhSkeletonWritten.Bones.Count - k].Children; if (resultList.Count != 0) { bonesListList.Add(resultList); break; } } } } BVHBone currentBone = bonesListList.Last().First(); string tabs = CalcTabs(currentBone); if (currentBone.Root == true) { file.WriteLine("ROOT " + currentBone.Name); } else if (currentBone.End == true) { file.WriteLine(tabs + "End Site"); } else { file.WriteLine(tabs + "JOINT " + currentBone.Name); } file.WriteLine(tabs + "{"); file.WriteLine(tabs + "\tOFFSET " + currentBone.translOffset[0].ToString().Replace(",", ".") + " " + currentBone.translOffset[1].ToString().Replace(",", ".") + " " + currentBone.translOffset[2].ToString().Replace(",", ".")); if (currentBone.End == true) { while (bonesListList.Count != 0 && bonesListList.Last().Count == 1) { tabs = CalcTabs(bonesListList.Last()[0]); foreach (List <BVHBone> liste in bonesListList) { if (liste.Contains(bonesListList.Last()[0])) { liste.Remove(bonesListList.Last()[0]); } } bonesListList.Remove(bonesListList.Last()); file.WriteLine(tabs + "}"); } if (bonesListList.Count != 0) { if (bonesListList.Last().Count != 0) { bonesListList.Last().Remove(bonesListList.Last()[0]); } else { bonesListList.Remove(bonesListList.Last()); } tabs = CalcTabs(bonesListList.Last()[0]); file.WriteLine(tabs + "}"); } } else { file.WriteLine(tabs + "\t" + WriteChannels(currentBone)); } bvhSkeleton.Bones.Remove(currentBone); bvhSkeletonWritten.AddBone(currentBone); } bvhSkeletonWritten.CopyParameters(bvhSkeleton); }