public static MotionPack LoadMotionPackFromMoPkg(Stream stream) { MotionPack motionPack = new MotionPack(); using (BinaryReader binaryReader = new BinaryReader(stream)) { Balthasar.IO.PackageLang pl = null; if (MotionPackReader.LoadHeader(ref motionPack, binaryReader, ref pl)) { long num = (long)((ulong)binaryReader.ReadUInt32()); if (motionPack.CompressMode == 1) { binaryReader.ReadUInt32(); byte[] array = binaryReader.ReadBytes((int)(num - 4L)); MemoryStream memoryStream = MotionPackReader.decompress(array); array = memoryStream.ToArray(); using (MemoryStream memoryStream2 = new MemoryStream(array)) { using (BinaryReader binaryReader2 = new BinaryReader(memoryStream2)) { MotionPackReader.LoadBody(ref motionPack, binaryReader2, ref pl); } } } } } return(motionPack); }
protected static MotionPack LoadMotionPackFromDMpkg(MotionPackUserInfo ui, Stream streamHeader, Stream streamContent) { MotionPack motionPack = new MotionPack(ui); bool flag = false; Balthasar.IO.PackageLang pl = null; using (BinaryReader binaryReader = new BinaryReader(streamHeader)) { flag = MotionPackReader.LoadHeader(ref motionPack, binaryReader, ref pl); } if (flag) { using (BinaryReader binaryReader2 = new BinaryReader(streamContent)) { long num = (long)((ulong)binaryReader2.ReadUInt32()); if (motionPack.CompressMode == 1) { binaryReader2.ReadUInt32(); byte[] array = binaryReader2.ReadBytes((int)(num - 4L)); MemoryStream memoryStream = MotionPackReader.decompress(array); array = memoryStream.ToArray(); using (MemoryStream memoryStream2 = new MemoryStream(array)) { using (BinaryReader binaryReader3 = new BinaryReader(memoryStream2)) { MotionPackReader.LoadBody(ref motionPack, binaryReader3, ref pl); } } } } } return(motionPack); }
public static void LoadBody(ref MotionPack pack, BinaryReader br, ref Balthasar.IO.PackageLang pl) { pack.Motions.Clear(); while (br.PeekChar() > -1) { MotionPackContainerID motionPackContainerID = (MotionPackContainerID)br.ReadInt32(); int num = br.ReadInt32(); switch (motionPackContainerID) { case MotionPackContainerID.MVH: pack.Motions.Add(MotionPackReader.readMVHContainer(br, num, ref pl)); break; case MotionPackContainerID.RepresentNames: MotionPackReader.readMotionRepresentnameContainer(br, ref pack, ref pl); break; case MotionPackContainerID.AnalyzeInformation: MotionPackReader.readAnalyzeInformationContainer(br, ref pack); break; default: br.BaseStream.Seek((long)num, SeekOrigin.Current); break; } } int num2 = 0; foreach (IDanceMotionLeaf current in pack.Motions) { current.IndexInMotionPack = num2; current.ParentMotionPack = pack; num2++; } }