public MMDDanceModel(CtMeshContainer mesh, Dictionary <string, BoneAssigner> bones) { this.Mesh = mesh; this.BoneTable = bones; this.BoneNames = ( from name in bones.Keys orderby name select name).ToArray <string>(); mesh.UpdateBoneMatrices(); this.AnkleHeight = mesh.MatrixPallet.TransformedMatrices[(int)((UIntPtr)bones["LeftAnkle"].Bone.MatrixIndex)].GetPosition().Y; }
public static MMDDanceModel LoadMMDModel(CtGraphicsInterface gi, string fileName) { CtMeshContainer ctMeshContainer = null; string text = Path.GetExtension(fileName).ToLower(); if (text.Equals(".ctmm")) { ctMeshContainer = CtModelFileLoader.LoadCTMM(fileName, gi); } else if (text.Equals(".pmd") || text.Equals(".pmx")) { ctMeshContainer = CtModelFileLoader.LoadPMD(fileName, gi); } Dictionary <string, BoneAssigner> dictionary = new Dictionary <string, BoneAssigner>(); CtMatrixPallet matrixPallet = ctMeshContainer.MatrixPallet; BoneAssigner boneAssigner = new BoneAssigner(matrixPallet.GetBone("下半身")); BoneAssigner value = new BoneAssigner(matrixPallet.GetBone("上半身"), boneAssigner); dictionary.Add("Hips", new BoneAssigner(matrixPallet.GetBone("センター"))); dictionary.Add("Chest", boneAssigner); dictionary.Add("Chest2", value); dictionary.Add("Neck", new BoneAssigner(matrixPallet.GetBone("首"))); dictionary.Add("Head", new BoneAssigner(matrixPallet.GetBone("頭"))); double num = CtMath.DegToRad(40.0); dictionary.Add("LeftCollar", new BoneAssigner(matrixPallet.GetBone("左肩"))); dictionary.Add("LeftShoulder", new BoneAssigner(matrixPallet.GetBone("左腕"), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), num), null)); dictionary.Add("LeftElbow", new BoneAssigner(matrixPallet.GetBone("左ひじ"), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), num), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), -num))); dictionary.Add("LeftWrist", new BoneAssigner(matrixPallet.GetBone("左手首"), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), num), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), -num))); dictionary.Add("RightCollar", new BoneAssigner(matrixPallet.GetBone("右肩"))); dictionary.Add("RightShoulder", new BoneAssigner(matrixPallet.GetBone("右腕"), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), -num), null)); dictionary.Add("RightElbow", new BoneAssigner(matrixPallet.GetBone("右ひじ"), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), -num), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), num))); dictionary.Add("RightWrist", new BoneAssigner(matrixPallet.GetBone("右手首"), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), -num), CtMatrix4x4.Rotate(new CtVector3D(0f, 0f, 1f), num))); dictionary.Add("LeftHip", new BoneAssigner(matrixPallet.GetBone("左足"))); dictionary.Add("LeftKnee", new BoneAssigner(matrixPallet.GetBone("左ひざ"))); dictionary.Add("LeftAnkle", new BoneAssigner(matrixPallet.GetBone("左足首"))); dictionary.Add("RightHip", new BoneAssigner(matrixPallet.GetBone("右足"))); dictionary.Add("RightKnee", new BoneAssigner(matrixPallet.GetBone("右ひざ"))); dictionary.Add("RightAnkle", new BoneAssigner(matrixPallet.GetBone("右足首"))); return(new MMDDanceModel(ctMeshContainer, dictionary)); }