public void GetFrameData_() { this.PlayingFrame += this.FrameStep; if (LoopAnimation && this.PlayingFrame > this.tags[this.playingIndex].maxtick - 1) { this.PlayingFrame = this.MinTick; } if (this.blksRaw[this.playingIndex] != null) { int t0 = Math.Max(0, Math.Min(this.blksRaw[this.playingIndex].cntFrames - 1, (int)Math.Floor(PlayingFrame))); int t1 = Math.Max(0, Math.Min(this.blksRaw[this.playingIndex].cntFrames - 1, (int)Math.Ceiling(PlayingFrame))); if (t0 == t1) { MsetRM rm = this.blksRaw[this.playingIndex].alrm[t0]; } else { MsetRM rm0 = this.blksRaw[this.playingIndex].alrm[t0]; float f1 = PlayingFrame % 1.0f; MsetRM rm1 = this.blksRaw[this.playingIndex].alrm[t1]; float f0 = 1.0f - f1; for (int t = 0; t < this.blksRaw[this.playingIndex].cntJoints; t++) { this.Skeleton.Bones[t].GlobalMatrix.M11 = rm0.al[t].M11 * f0 + rm1.al[t].M11 * f1; this.Skeleton.Bones[t].GlobalMatrix.M21 = rm0.al[t].M21 * f0 + rm1.al[t].M21 * f1; this.Skeleton.Bones[t].GlobalMatrix.M31 = rm0.al[t].M31 * f0 + rm1.al[t].M31 * f1; this.Skeleton.Bones[t].GlobalMatrix.M41 = rm0.al[t].M41 * f0 + rm1.al[t].M41 * f1; this.Skeleton.Bones[t].GlobalMatrix.M12 = rm0.al[t].M12 * f0 + rm1.al[t].M12 * f1; this.Skeleton.Bones[t].GlobalMatrix.M22 = rm0.al[t].M22 * f0 + rm1.al[t].M22 * f1; this.Skeleton.Bones[t].GlobalMatrix.M32 = rm0.al[t].M32 * f0 + rm1.al[t].M32 * f1; this.Skeleton.Bones[t].GlobalMatrix.M42 = rm0.al[t].M42 * f0 + rm1.al[t].M42 * f1; this.Skeleton.Bones[t].GlobalMatrix.M13 = rm0.al[t].M13 * f0 + rm1.al[t].M13 * f1; this.Skeleton.Bones[t].GlobalMatrix.M23 = rm0.al[t].M23 * f0 + rm1.al[t].M23 * f1; this.Skeleton.Bones[t].GlobalMatrix.M33 = rm0.al[t].M33 * f0 + rm1.al[t].M33 * f1; this.Skeleton.Bones[t].GlobalMatrix.M43 = rm0.al[t].M43 * f0 + rm1.al[t].M43 * f1; this.Skeleton.Bones[t].GlobalMatrix.M14 = rm0.al[t].M14 * f0 + rm1.al[t].M14 * f1; this.Skeleton.Bones[t].GlobalMatrix.M24 = rm0.al[t].M24 * f0 + rm1.al[t].M24 * f1; this.Skeleton.Bones[t].GlobalMatrix.M34 = rm0.al[t].M34 * f0 + rm1.al[t].M34 * f1; this.Skeleton.Bones[t].GlobalMatrix.M44 = rm0.al[t].M44 * f0 + rm1.al[t].M44 * f1; } } } else { this.olS.getMats(this.skelStream, this.blks[this.playingIndex].cntb1, this.msetStream, this.blks[this.playingIndex].cntb2, this.Moveset.al1[this.playingIndex].off, PlayingFrame); //if (this.Master!=null) // Mlink.MatrixBuffer[0] += this.Master.Skeleton.Bones[this.Master.Skeleton.LeftHandBone].Matrix; //Console.WriteLine(this.blks[this.playingIndex].cntb1); for (int t = 0; t < this.blks[this.playingIndex].cntb1; t++) { this.Skeleton.Bones[t].GetSRT(Mlink.MatrixBuffer[t]); this.Skeleton.Bones[t].DirtyMatrix = true; this.Skeleton.Bones[t].GlobalMatrix = this.Skeleton.Bones[t].LocalMatrix; } } }
public void ExportBinary() { if (!Directory.Exists(Path.GetDirectoryName(this.FileName) + @"\exportedMSET")) { Directory.CreateDirectory(Path.GetDirectoryName(this.FileName) + @"\exportedMSET"); } for (int i = 0; i < this.blksRaw.Length; i++) { FileStream outputStream = new FileStream(Path.GetDirectoryName(this.FileName) + @"\exportedMSET\move_" + i.ToString("d3") + ".bin", FileMode.OpenOrCreate); BinaryWriter bw = new BinaryWriter(outputStream); if (false && File.Exists(Path.GetDirectoryName(this.FileName) + @"\MSET\move_" + i.ToString("d3") + ".bin")) { FileStream inputStream = new FileStream(Path.GetDirectoryName(this.FileName) + @"\MSET\move_" + i.ToString("d3") + ".bin", FileMode.Open); BinaryReader br = new BinaryReader(inputStream); bw.Write(br.ReadInt32()); bw.Write(br.ReadInt32()); bw.Write(br.ReadInt32()); bw.Write(br.ReadInt32()); br.Close(); inputStream.Close(); } else { bw.Write((int)this.tags[i].maxtick); bw.Write(0); bw.Write(0); bw.Write(0); } for (int j = 0; j < (int)this.tags[i].maxtick; j++) { if (this.blksRaw[i] != null) { int t0 = Math.Max(0, Math.Min(this.blksRaw[i].cntFrames - 1, (int)Math.Floor((double)j))); int t1 = Math.Max(0, Math.Min(this.blksRaw[i].cntFrames - 1, (int)Math.Ceiling((double)j))); if (t0 == t1) { MsetRM rm = this.blksRaw[i].alrm[t0]; } else { MsetRM rm0 = this.blksRaw[i].alrm[t0]; float f1 = j % 1.0f; MsetRM rm1 = this.blksRaw[i].alrm[t1]; float f0 = 1.0f - f1; for (int t = 0; t < this.blksRaw[i].cntJoints; t++) { Matrix m = Matrix.Identity; m.M11 = (rm0.al[t].M11 * f0 + rm1.al[t].M11 * f1); m.M12 = (rm0.al[t].M12 * f0 + rm1.al[t].M12 * f1); m.M13 = (rm0.al[t].M13 * f0 + rm1.al[t].M13 * f1); m.M14 = (rm0.al[t].M14 * f0 + rm1.al[t].M14 * f1); m.M21 = (rm0.al[t].M21 * f0 + rm1.al[t].M21 * f1); m.M22 = (rm0.al[t].M22 * f0 + rm1.al[t].M22 * f1); m.M23 = (rm0.al[t].M23 * f0 + rm1.al[t].M23 * f1); m.M24 = (rm0.al[t].M24 * f0 + rm1.al[t].M24 * f1); m.M31 = (rm0.al[t].M31 * f0 + rm1.al[t].M31 * f1); m.M32 = (rm0.al[t].M32 * f0 + rm1.al[t].M32 * f1); m.M33 = (rm0.al[t].M33 * f0 + rm1.al[t].M33 * f1); m.M34 = (rm0.al[t].M34 * f0 + rm1.al[t].M34 * f1); m.M41 = (rm0.al[t].M41 * f0 + rm1.al[t].M41 * f1); m.M42 = (rm0.al[t].M42 * f0 + rm1.al[t].M42 * f1); m.M43 = (rm0.al[t].M43 * f0 + rm1.al[t].M43 * f1); m.M44 = (rm0.al[t].M44 * f0 + rm1.al[t].M44 * f1); this.Skeleton.Bones[t].localMatrix = m; this.Skeleton.Bones[t].DirtyMatrix = true; } } } else { this.olS.getMats(this.skelStream, this.blks[i].cntb1, this.msetStream, this.blks[i].cntb2, this.Moveset.al1[i].off, j); for (int t = 0; t < this.blks[i].cntb1; t++) { Matrix m = Matrix.Identity; m.M11 = (Mlink.MatrixBuffer[t].M11); m.M12 = (Mlink.MatrixBuffer[t].M12); m.M13 = (Mlink.MatrixBuffer[t].M13); m.M14 = (Mlink.MatrixBuffer[t].M14); m.M21 = (Mlink.MatrixBuffer[t].M21); m.M22 = (Mlink.MatrixBuffer[t].M22); m.M23 = (Mlink.MatrixBuffer[t].M23); m.M24 = (Mlink.MatrixBuffer[t].M24); m.M31 = (Mlink.MatrixBuffer[t].M31); m.M32 = (Mlink.MatrixBuffer[t].M32); m.M33 = (Mlink.MatrixBuffer[t].M33); m.M34 = (Mlink.MatrixBuffer[t].M34); m.M41 = (Mlink.MatrixBuffer[t].M41); m.M42 = (Mlink.MatrixBuffer[t].M42); m.M43 = (Mlink.MatrixBuffer[t].M43); m.M44 = (Mlink.MatrixBuffer[t].M44); this.Skeleton.Bones[t].localMatrix = m; this.Skeleton.Bones[t].DirtyMatrix = true; } } Unwrap(); for (int k = 0; k < this.Skeleton.Bones.Count; k++) { bw.Write(this.Skeleton.Bones[k].localMatrix.M11); bw.Write(this.Skeleton.Bones[k].localMatrix.M12); bw.Write(this.Skeleton.Bones[k].localMatrix.M13); bw.Write(this.Skeleton.Bones[k].localMatrix.M14); bw.Write(this.Skeleton.Bones[k].localMatrix.M21); bw.Write(this.Skeleton.Bones[k].localMatrix.M22); bw.Write(this.Skeleton.Bones[k].localMatrix.M23); bw.Write(this.Skeleton.Bones[k].localMatrix.M24); bw.Write(this.Skeleton.Bones[k].localMatrix.M31); bw.Write(this.Skeleton.Bones[k].localMatrix.M32); bw.Write(this.Skeleton.Bones[k].localMatrix.M33); bw.Write(this.Skeleton.Bones[k].localMatrix.M34); bw.Write(this.Skeleton.Bones[k].localMatrix.M41); bw.Write(this.Skeleton.Bones[k].localMatrix.M42); bw.Write(this.Skeleton.Bones[k].localMatrix.M43); bw.Write(this.Skeleton.Bones[k].localMatrix.M44); } } bw.Close(); outputStream.Close(); } }