//------------------------------------------// // 関数名 Update // // Function Update // 機能 モデルのボーン情報を更新する // // Update the information of bone functional model // 引数 スケルトンデータ // // Argument skeleton data // 戻り値 なし // // No return value //------------------------------------------// public void Update(Skeleton skeleton, AnimationPlayer animationPlayer, bool JumpAnimate, bool KickAnimate, bool DuckAnimate, bool KnockAnimate) { // Get information of skin model var skinningData = this.model.Tag as SkinningData; // To reflect the skeletal data of Kinect for bone information on which to base the model var worldBindPose = new Matrix[skinningData.BindPose.Count]; testMatrix = new Matrix[skinningData.BindPose.Count]; // animation transformation matrix Matrix[] bones; if (animationPlayer != null) { //bones = animationPlayer.GetSkinTransforms(); bones = animationPlayer.GetBoneTransforms(); } else { bones = new Matrix[(int)BoneType.MaxBone]; } for (var boneIndex = 0; boneIndex < skinningData.BindPose.Count; boneIndex++) { // I get the bone information on which to base var boneTransform = skinningData.BindPose[boneIndex]; var parentBoneIndex = skinningData.SkeletonHierarchy[boneIndex]; if (parentBoneIndex > -1) { // I synthesize the bone information of parents who completed the reflection boneTransform *= worldBindPose[parentBoneIndex]; boneTransform = bones[boneIndex] * worldBindPose[parentBoneIndex]; } else { boneTransform = bones[boneIndex]; } // To reflect the coordinates of the joint according to the bone switch (this.boneIndices[boneIndex]) { case BoneType.Hip: { if (JumpAnimate || KickAnimate || DuckAnimate || KnockAnimate) { } else { // TransformRootBone(skeleton, ref boneTransform); } } break; case BoneType.Head: { if (JumpAnimate || DuckAnimate || KnockAnimate) { } else { TransformNodeBone(skeleton, JointType.Head, JointType.ShoulderCenter, ref boneTransform); } } break; case BoneType.Spine: { if (JumpAnimate || DuckAnimate) { } else { TransformNodeBone(skeleton, JointType.ShoulderCenter, JointType.HipCenter, ref boneTransform); } } break; case BoneType.UpperArmRight: { if (JumpAnimate || DuckAnimate) { } else { TransformNodeBone(skeleton, JointType.ShoulderRight, JointType.ElbowRight, ref boneTransform); } } break; case BoneType.ForeArmRight: { if (JumpAnimate || DuckAnimate) { } else { TransformNodeBone(skeleton, JointType.ElbowRight, JointType.WristRight, ref boneTransform); } } break; case BoneType.HandRight: { if (JumpAnimate || DuckAnimate) { } else { TransformNodeBone(skeleton, JointType.WristRight, JointType.HandRight, ref boneTransform); } } break; case BoneType.UpperArmLeft: { if (JumpAnimate || DuckAnimate) { } else { TransformNodeBone(skeleton, JointType.ShoulderLeft, JointType.ElbowLeft, ref boneTransform); } } break; case BoneType.ForeArmLeft: { if (JumpAnimate || DuckAnimate) { } else { TransformNodeBone(skeleton, JointType.ElbowLeft, JointType.WristLeft, ref boneTransform); } } break; case BoneType.HandLeft: { if (JumpAnimate || DuckAnimate) { } else { TransformNodeBone(skeleton, JointType.WristLeft, JointType.HandLeft, ref boneTransform); } } break; case BoneType.ThighRight: { if (JumpAnimate || KickAnimate || KnockAnimate) { //boneTransform = worldBindPose[parentBoneIndex] * bones[boneIndex]; //boneTransform = skinningData.BindPose[boneIndex];// *worldBindPose[parentBoneIndex]; } else { //TransformNodeBone(skeleton, JointType.HipRight, JointType.KneeRight, ref boneTransform); } } break; case BoneType.ShinRight: { if (JumpAnimate || KickAnimate || KnockAnimate) { } else { // TransformNodeBone(skeleton, JointType.KneeRight, JointType.AnkleRight, ref boneTransform); } } break; case BoneType.FootRight: { if (JumpAnimate || KickAnimate || KnockAnimate) { } else { //TransformNodeBone(skeleton, JointType.AnkleRight, JointType.FootRight, ref boneTransform); } } break; case BoneType.ThighLeft: { if (JumpAnimate || KickAnimate || KnockAnimate) { } else { // TransformNodeBone(skeleton, JointType.HipLeft, JointType.KneeLeft, ref boneTransform); } } break; case BoneType.ShinLeft: { if (JumpAnimate || KickAnimate || KnockAnimate) { } else { // TransformNodeBone(skeleton, JointType.KneeLeft, JointType.AnkleLeft, ref boneTransform); } } break; case BoneType.FootLeft: { if (JumpAnimate || KickAnimate || KnockAnimate) { } else { //TransformNodeBone(skeleton, JointType.AnkleLeft, JointType.FootLeft, ref boneTransform); } } break; } worldBindPose[boneIndex] = boneTransform; testMatrix[boneIndex] = boneTransform; // To be stored in the field by converting the coordinate system of the bone information this.boneTransforms[boneIndex] = skinningData.InverseBindPose[boneIndex] * worldBindPose[boneIndex]; //testMatrix = boneTransforms; } }