示例#1
0
 public Bone(JointType parentJoint, JointType childJoint, Bone parentBone)
 {
     ParentJoint = parentJoint;
     ChildJoint = childJoint;
     ParentBone = parentBone;
     Rotation = Quaternion.identity;
     TrackingState = BoneTrackingState.NotTracked;
 }
示例#2
0
        private void UpdateBone(Bone bone, Body body)
        {
            var joints = body.Joints;
            Joint parentJoint = joints[bone.ParentJoint];
            Joint childJoint = joints[bone.ChildJoint];

            bone.TrackingState = GetBoneTrackingState(parentJoint, childJoint);

            var orientation = body.JointOrientations[bone.ChildJoint].Orientation;

            Quaternion q = new Quaternion(orientation.X, orientation.Y, orientation.Z, orientation.W);

            //Vector3 parentVector = GetBoneVector(nearJoint, parentJoint);
            //Vector3 childVector = GetBoneVector(parentJoint, childJoint);

            //Quaternion quaternion = GetQuaternionForVectors(parentVector, childVector);

            bone.Rotation = q;
        }
示例#3
0
        public Bone AddChildBone(JointType childJoint)
        {
            var childBone = new Bone(ChildJoint, childJoint, this);
            ChildBones.Add(childBone);

            return childBone;
        }
示例#4
0
        private void CreateParentChildBones()
        {
            _rootBone = new Bone(JointType.SpineShoulder);
            _rootBone.AddChildBone(JointType.Neck)
                    .AddChildBone(JointType.Head);

            var handLeft = _rootBone.AddChildBone(JointType.ShoulderLeft)
                                   .AddChildBone(JointType.ElbowLeft)
                                   .AddChildBone(JointType.WristLeft)
                                   .AddChildBone(JointType.HandLeft);

            handLeft.AddChildBone(JointType.HandTipLeft);
            handLeft.AddChildBone(JointType.ThumbLeft);

            var handRight = _rootBone.AddChildBone(JointType.ShoulderRight)
                                    .AddChildBone(JointType.ElbowRight)
                                    .AddChildBone(JointType.WristRight)
                                    .AddChildBone(JointType.HandRight);

            handRight.AddChildBone(JointType.HandTipRight);
            handRight.AddChildBone(JointType.ThumbRight);
        }