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(); }
private static void SetBoneRotation(BoneAssigner bone, CtMatrix4x4 tm) { CtMatrix4x4 ctMatrix4x = CtMatrix4x4.UnitMatrix(); for (CtBone ctBone = bone.Bone; ctBone != null; ctBone = ctBone.Parent) { ctMatrix4x *= ctBone.InitMatrix; } CtMatrix4x4 ctMatrix4x2 = CtMatrix4x4.UnitMatrix(); CtVector3D[] array = new CtVector3D[] { CtMatrix4x4.Mulv3xM4N(new CtVector3D(1f, 0f, 0f), ctMatrix4x), CtMatrix4x4.Mulv3xM4N(new CtVector3D(0f, 1f, 0f), ctMatrix4x), CtMatrix4x4.Mulv3xM4N(new CtVector3D(0f, 0f, 1f), ctMatrix4x) }; array[0].Normalize(); array[1].Normalize(); array[2].Normalize(); ctMatrix4x2.SetAxis3(array[0], array[1], array[2]); ctMatrix4x2.Transpose(); CtMatrix4x4 ctMatrix4x3 = new CtMatrix4x4(ctMatrix4x2); CtMatrix4x4.Inverse(ctMatrix4x3); CtMatrix4x4 leftMatrix = bone.LeftMatrix; CtMatrix4x4 rightMatrix = bone.RightMatrix; bone.Bone.TransformMatrix = ctMatrix4x2 * leftMatrix * tm * rightMatrix * ctMatrix4x3; }
public void CleanPose() { for (int i = 0; i < this.Mesh.MatrixPallet.GetBoneCount(); i++) { CtBone bone = this.Mesh.MatrixPallet.GetBone(i); bone.TransformMatrix = CtMatrix4x4.UnitMatrix(); } this.Mesh.UpdateBoneMatrices(); }
private bool setBoneAsNativeBoneName(string boneName, BoneState boneState) { CtBone bone = this.Mesh.MatrixPallet.GetBone(boneName); if (bone != null) { bone.TransformMatrix = CtMatrix4x4.Rotate(boneState.Rotate); } return(bone != null); }
public BoneAssigner(CtBone bone, CtMatrix4x4 leftMatrix, CtMatrix4x4 rightMatrix) { this.Bone = bone; this.LeftMatrix = leftMatrix; this.RightMatrix = rightMatrix; if (this.LeftMatrix == null) { this.LeftMatrix = CtMatrix4x4.UnitMatrix(); } if (this.RightMatrix == null) { this.RightMatrix = CtMatrix4x4.UnitMatrix(); } this.ParentBone = null; }
public BoneAssigner(CtBone bone, BoneAssigner parent) : this(bone, null, null) { this.ParentBone = parent; }
public BoneAssigner(CtBone bone) : this(bone, null, null) { }