Пример #1
0
        public static MotFile Deserialize(Stream stream, bool FMode)
        {
            var serializer = new BinarySerializer();
            var file       = new MotFile();

            file.Header = serializer.Deserialize <MotHeader>(stream);

            while (stream.Position < file.Header.InfoOffset)
            {
                file.SubHeaders.Add(serializer.Deserialize <MotHeader>(stream));
            }

            var anim = new MotAnim();

            anim.Deserialize(stream, file.Header, file.SubHeaders[0].InfoOffset, FMode);

            file.Animations.Add(anim);

            for (var i = 0; i < file.SubHeaders.Count; i++)
            {
                if (file.SubHeaders[i].InfoOffset == 0)
                {
                    continue;
                }
                anim = new MotAnim();
                var boneEnd = 0;
                try { boneEnd = file.SubHeaders[i + 1].InfoOffset; }
                catch { /* ignored */ }
                anim.Deserialize(stream, file.SubHeaders[i], boneEnd, FMode);
                file.Animations.Add(anim);
            }
            return(file);
        }
Пример #2
0
        private static void Main(string[] args)
        {
            const string path = @"D:\QuickBMS\dt_anim\mot_PV007.bin";

            //const string path = @"D:\QuickBMS\f_anim\mot_PV626.bin";
            //const string path = @"D:\QuickBMS\f_anim\mot_PV626_tst.bin";
            using (var file = new FileStream(path, FileMode.Open))
            {
                var serializer = new BinarySerializer();
                //var motFile = serializer.Deserialize<MotFile>(file);
                var motFile = MotFile.Deserialize(file, false);
                Console.WriteLine(motFile.GetMotData(0, 0).FrameCount);
                //const string savePath = @"D:\QuickBMS\f_anim\mot_PV056.bin";
                const string SavePath = @"D:\QuickBMS\modify_mot\mot_PV007.bin";
                //const string SavePath = @"D:\QuickBMS\modify_mot\mot_PV007.xml";

                /*
                 * using (var save = new FileStream(SavePath, FileMode.Create))
                 * {
                 *  var doc = new XmlDocument();
                 *  var root = doc.CreateElement("animation");
                 *  var wrapper = doc.CreateElement("ikAnim");
                 *  foreach (var value in motFile.Animations[0].Data[24].Values)
                 *  {
                 *      var element = doc.CreateElement("axis");
                 *      element.InnerText = $"(X={value.Value},Y=0.0,Z=0.0)";
                 *
                 *  }
                 *  var leftHand = motFile.Animations[0].Data[24];
                 *  var leftHand1 = motFile.Animations[0].Data[24];
                 *  var leftHand2 = motFile.Animations[0].Data[24];
                 *
                 *  for (var index = 0; index < leftHand.FrameCount; index++)
                 *  {
                 *      var element = doc.CreateElement("axis");
                 *      var frame = doc.CreateElement("frame");
                 *      frame.InnerText = $"{leftHand.Frames[index]}";
                 *      element.InnerText = $"(X={leftHand.Values[index].Value},Y={leftHand1.Values[index].Value},Z={leftHand2.Values[index].Value})";
                 *
                 *      wrapper.AppendChild(frame);
                 *      wrapper.AppendChild(element);
                 *  }
                 *  root.AppendChild(wrapper);
                 *  doc.AppendChild(root);
                 *  doc.Save(save);
                 * }
                 */
                Console.WriteLine(motFile.GetMotData(0, 0).FrameCount);
                var archive = new FarcArchive
                {
                    new FarcEntry
                    {
                        FileName = Path.GetFileName(SavePath),
                        FilePath = new FileInfo(SavePath)
                    }
                };

                var farcDirectory = @"D:\Emulators\RPSC3\dev_hdd0\game\NPJB00134\USRDIR\rom\rob\" + Path.ChangeExtension(archive[0].FileName, ".farc");
                //var farcDirectory = @"D:\Emulators\RPSC3\dev_hdd0\disc\BLJM60527\PS3_GAME\USRDIR\rom\rob" + Path.ChangeExtension(archive[0].FileName, ".farc");
                archive.Save(farcDirectory);
            }
        }