public void SetPose(DancePose pose) { if (pose.FootState == DancePoseFootState.Auto) { CtMatrix4x4[] transformedMatrices = this.Mesh.MatrixPallet.TransformedMatrices; uint matrixIndex = this.BoneTable["LeftAnkle"].Bone.MatrixIndex; uint matrixIndex2 = this.BoneTable["RightAnkle"].Bone.MatrixIndex; CtVector3D position = transformedMatrices[(int)((UIntPtr)matrixIndex)].GetPosition(); CtVector3D position2 = transformedMatrices[(int)((UIntPtr)matrixIndex2)].GetPosition(); bool flag = position.Y < position2.Y; CtVector3D a = flag ? position : position2; a.Y = this.AnkleHeight; this.SetPoseWithoutPivoting(pose); this.Mesh.UpdateBoneMatrices(); CtVector3D position3 = (flag ? transformedMatrices[(int)((UIntPtr)matrixIndex)] : transformedMatrices[(int)((UIntPtr)matrixIndex2)]).GetPosition(); CtBone bone = this.BoneTable["Hips"].Bone; bone.TransformMatrix = CtMatrix4x4.MulM4xM4(bone.TransformMatrix, CtMatrix4x4.Translate(a - position3)); this.Mesh.UpdateBoneMatrices(); return; } this.SetPoseWithoutPivoting(pose); CtBone bone2 = this.Mesh.MatrixPallet.GetBone(MMDDanceModel.mmdBoneNameOfROOT); CtBone bone3 = this.Mesh.MatrixPallet.GetBone(MMDDanceModel.mmdBoneNameOfLOWERBODY); float f = -bone3.OffsetMatrix.GetPosition().Y; CtVector3D position4 = bone2.TransformedMatrix.GetPosition(); CtVector3D position5 = bone3.TransformedMatrix.GetPosition(); CtVector3D b = position4 - position5 + bone2.OffsetMatrix.GetPosition(); bone2.TransformMatrix.TranslateFromRight(f * pose.BodyPosition + b); this.Mesh.UpdateBoneMatrices(); }
protected override DanceMotion ReadTarget(BinaryReader reader, IReadingSession session) { string name = reader.ReadMoostaString(); int beatCount = reader.ReadInt32(); string[] array = new string[reader.ReadInt32()]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadMoostaString(); } string[] array2 = new string[reader.ReadInt32()]; for (int j = 0; j < array2.Length; j++) { array2[j] = reader.ReadMoostaString(); } DancePose[] array3 = new DancePose[reader.ReadInt32()]; for (int k = 0; k < array3.Length; k++) { BoneState[] array4 = new BoneState[array2.Length]; for (int l = 0; l < array2.Length; l++) { array4[l] = new BoneState(new CtQuaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle())); } array3[k] = new DancePose(array2, array4); } return(new DanceMotion(name, beatCount, array3, null) { Tags = array }); }
void ReorderBuffer(int i) { hitCounter = 0; DancePose tmp = buffer[i]; buffer.Clear(); buffer.Add(tmp); CheckForCombo(0); }
private static DanceMotion createFromBvhMotion(string name, BvhMotion bvhMotion, int beatCount, string[] bones) { Array.Sort <string>(bones); DancePose[] array = new DancePose[bvhMotion.Count]; for (int i = 0; i < array.Length; i++) { array[i] = DanceMotionFactoryFromBVH.createPoseFromBvhPose(bvhMotion.RootNode, bvhMotion[i], bones); } return(new DanceMotion(name, beatCount, array, null)); }
protected override void WriteTarget(BinaryWriter writer, DanceMotion target, IWritingSession session) { writer.WriteMoostaString(target.Name); writer.Write(target.BeatCount); writer.Write((target.SourceDanceModel == null) ? 0 : session.GetKey(target.SourceDanceModel)); writer.Write(target.Tags.Length); string[] tags = target.Tags; for (int i = 0; i < tags.Length; i++) { string str = tags[i]; writer.WriteMoostaString(str); } string[] boneNames = target.FirstPose.BoneNames; writer.Write(boneNames.Length); string[] array = boneNames; for (int j = 0; j < array.Length; j++) { string str2 = array[j]; writer.WriteMoostaString(str2); } string[] skinNames = target.FirstPose.SkinNames; writer.Write(skinNames.Length); string[] array2 = skinNames; for (int k = 0; k < array2.Length; k++) { string str3 = array2[k]; writer.WriteMoostaString(str3); } writer.Write(target.Poses.Length); DancePose[] poses = target.Poses; for (int l = 0; l < poses.Length; l++) { DancePose dancePose = poses[l]; writer.Write(dancePose.BodyPosition.X); writer.Write(dancePose.BodyPosition.Y); writer.Write(dancePose.BodyPosition.Z); writer.Write((int)dancePose.FootState); string[] array3 = boneNames; for (int m = 0; m < array3.Length; m++) { string boneName = array3[m]; CtQuaternion rotate = dancePose[boneName].Rotate; writer.Write(rotate.X); writer.Write(rotate.Y); writer.Write(rotate.Z); writer.Write(rotate.W); } string[] array4 = skinNames; for (int n = 0; n < array4.Length; n++) { string skinName = array4[n]; writer.Write(dancePose.GetSkinState(skinName).Weight); } } }
private void SetPoseWithoutPivoting(DancePose pose) { string[] boneNames = pose.BoneNames; for (int i = 0; i < boneNames.Length; i++) { string boneName = boneNames[i]; BoneState boneState = pose[boneName]; if (!this.setBoneAsNativeBoneName(boneName, boneState) && !this.setBoneViaMMDBoneName(boneName, boneState)) { this.setBoneAsBVHBoneName(boneName, boneState); } } }
private DancePose[] getDancePose(int frameCount, List <MFuriKeyFrameList> keyFrameLists, string[] bones) { DancePose[] array = new DancePose[frameCount]; for (int i = 0; i < array.Length; i++) { array[i] = new DancePose(bones); foreach (MFuriKeyFrameList current in keyFrameLists) { BoneState value = new BoneState(current.KeyFrames[i].Rotation); array[i][current.BoneName] = value; } } return(array); }
protected override DanceMotion ReadTarget(BinaryReader reader, IReadingSession session) { string name = reader.ReadMoostaString(); int beatCount = reader.ReadInt32(); int num = reader.ReadInt32(); DanceModelInfo sourceModel = (num == 0) ? null : (session.GetObject(num) as DanceModelInfo); string[] array = new string[reader.ReadInt32()]; for (int i = 0; i < array.Length; i++) { array[i] = reader.ReadMoostaString(); } string[] array2 = new string[reader.ReadInt32()]; for (int j = 0; j < array2.Length; j++) { array2[j] = reader.ReadMoostaString(); } string[] array3 = new string[reader.ReadInt32()]; for (int k = 0; k < array3.Length; k++) { array3[k] = reader.ReadMoostaString(); } DancePose[] array4 = new DancePose[reader.ReadInt32()]; for (int l = 0; l < array4.Length; l++) { CtVector3D bodyPos = new CtVector3D(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); DancePoseFootState footState = (DancePoseFootState)reader.ReadInt32(); BoneState[] array5 = new BoneState[array2.Length]; for (int m = 0; m < array2.Length; m++) { array5[m] = new BoneState(new CtQuaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle())); } SkinState[] array6 = new SkinState[array3.Length]; for (int n = 0; n < array3.Length; n++) { array6[n] = new SkinState(reader.ReadSingle()); } array4[l] = new DancePose(array2, array5, array3, array6, bodyPos) { FootState = footState }; } return(new DanceMotion(name, beatCount, array4, sourceModel) { Tags = array }); }
protected override void WriteTarget(BinaryWriter writer, DanceMotion target, IWritingSession session) { writer.WriteMoostaString(target.Name); writer.Write(target.BeatCount); writer.Write(target.Tags.Length); string[] tags = target.Tags; for (int i = 0; i < tags.Length; i++) { string str = tags[i]; writer.WriteMoostaString(str); } string[] boneNames = target.FirstPose.BoneNames; writer.Write(boneNames.Length); string[] array = boneNames; for (int j = 0; j < array.Length; j++) { string str2 = array[j]; writer.WriteMoostaString(str2); } writer.Write(target.Poses.Length); DancePose[] poses = target.Poses; for (int k = 0; k < poses.Length; k++) { DancePose dancePose = poses[k]; string[] array2 = boneNames; for (int l = 0; l < array2.Length; l++) { string boneName = array2[l]; CtQuaternion rotate = dancePose[boneName].Rotate; writer.Write(rotate.X); writer.Write(rotate.Y); writer.Write(rotate.Z); writer.Write(rotate.W); } } }