Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pack"></param>
        /// <param name="PlCoPath"></param>
        /// <param name="internalID"></param>
        /// <param name="editor"></param>
        /// <returns>true if bone table was injected</returns>
        private bool RemoveBoneTableEntry(string PlCoPath)
        {
            Console.WriteLine($"Removing Bone Table Entry...");

            var plco = new HSDRawFile(PlCoPath);

            if (plco.Roots[0].Data is ftLoadCommonData commonData)
            {
                var boneTables = commonData.BoneTables.Array.ToList();

                // This PlCo is invalid since it contains a different number of entries than expected
                if (boneTables.Count - 1 != editor.FighterControl.NumberOfEntries)
                {
                    throw new InvalidDataException("PlCo Table was invalid");
                    //return false;
                }

                boneTables.RemoveAt(internalID);
                commonData.BoneTables.Array = boneTables.ToArray();
            }
            else
            {
                return(false);
            }

            editedFiles.Add(new Tuple <HSDRawFile, string, bool>(plco, PlCoPath, false));

            return(true);
        }
        //private static AfterImageDesc after_desc = new AfterImageDesc()
        //{
        //    Bone = 57,//27,
        //    Bottom = 0,
        //    Top = 4,
        //    Color1 = new Vector3(1, 1, 1),
        //    Color2 = new Vector3(0, 1, 1)
        //};
        //private static AfterImageDesc after_desc = new AfterImageDesc()
        //{
        //    Bone = 75,
        //    Bottom = 1.75f,
        //    Top = 9.63f,
        //    Color1 = new Vector3(1, 1, 1),
        //    Color2 = new Vector3(0, 1, 1)
        //};

        /// <summary>
        ///
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="size"></param>
        private void LoadAnimation(string symbol)
        {
            // reset display sheild size
            DisplayShieldSize = 0;

            // check if animations are loaded
            if (AJManager == null)
            {
                return;
            }

            // check if animation exists
            var animData = AJManager.GetAnimationData(symbol);

            if (animData == null)
            {
                return;
            }

            // load animation
            var anim = new HSDRawFile(animData);

            if (anim.Roots[0].Data is HSD_FigaTree tree)
            {
                LoadFigaTree(anim.Roots[0].Name, tree);
            }


            if (FrameSpeedModifiers.Count > 0)
            {
                UpdateAnimationWithFSMs();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 public void SetFromFile(string filePath)
 {
     try
     {
         var figaFile = new HSDRawFile(filePath);
         if (figaFile.Roots.Count > 0 && figaFile.Roots[0].Data is HSD_FigaTree tree)
         {
             if (figaFile.Roots[0].Name.Equals(Name))
             {
                 Data = File.ReadAllBytes(filePath);
             }
             else
             {
                 // rename symbol if necessary
                 //if(MessageBox.Show($"The animation symbol does not match./nRename It?\n{Name}\n{figaFile.Roots[0].Name}", "Symbol Mismatch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
                 {
                     figaFile.Roots[0].Name = Name;
                     using (MemoryStream stream = new MemoryStream())
                     {
                         figaFile.Save(stream);
                         Data = stream.ToArray();
                     }
                 }
             }
         }
     }
     catch
     {
         MessageBox.Show("Error replacing animation", "Animation Replace Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openPldatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var f = Tools.FileIO.OpenFile("Player DAT (Pl**.dat)|*.dat");

            if (f != null)
            {
                ResultAnimations.Clear();
                FightingAnimations.Clear();
                PlayerFile   = null;
                PlayerData   = null;
                AJLoaded     = false;
                ResultLoaded = false;

                var file = new HSDRawFile(f);

                foreach (var root in file.Roots)
                {
                    if (root.Data is SBM_FighterData plData)
                    {
                        ftDataPath                          = f;
                        PlayerFile                          = file;
                        PlayerData                          = plData;
                        FighterName                         = root.Name.Replace("ftData", "");
                        Text                                = "AJ Split - " + FighterName;
                        buttonLoadAnims.Enabled             = true;
                        buttonLoadResult.Enabled            = true;
                        exportDATsToolStripMenuItem.Enabled = true;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public bool DoIt(string[] args)
        {
            if (args.Length >= 6)
            {
                // parse args
                var inputjoint     = Path.GetFullPath(args[1]);
                var inputBoneMap   = new BoneMap(Path.GetFullPath(args[2]));
                var targetjoint    = Path.GetFullPath(args[3]);
                var targetBoneMap  = new BoneMap(Path.GetFullPath(args[4]));
                var inputfigatree  = Path.GetFullPath(args[5]);
                var outputfigatree = Path.GetFullPath(args[6]);

                // source joint
                HSDRawFile inputJoint = new HSDRawFile(inputjoint);
                var        sourceJOBJ = inputJoint.Roots[0].Data as HSD_JOBJ;

                // target joint
                HSDRawFile targetJoint = new HSDRawFile(targetjoint);
                var        targetJOBJ  = targetJoint.Roots[0].Data as HSD_JOBJ;

                // retarget animation
                HSDRawFile inputAnim = new HSDRawFile(inputfigatree);
                var        tree      = inputAnim.Roots[0].Data as HSD_FigaTree;

                inputAnim.Roots[0].Data = AnimationBakery.Port(tree, sourceJOBJ, targetJOBJ, inputBoneMap, targetBoneMap);
                inputAnim.Save(outputfigatree);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        public void OpenFile(string filePath)
        {
            FilePath = filePath;

            RawHSDFile = new HSDRawFile();
            RawHSDFile.Open(filePath);
            RefreshTree();

#if !DEBUG
            if (RawHSDFile.Roots.Count > 0 && RawHSDFile.Roots[0].Data is HSDRaw.MEX.MEX_Data)
            {
                if (nodeBox.Visible)
                {
                    // hide nodes
                    showHideButton_Click(null, null);

                    // select the mexData node
                    treeView1.SelectedNode = treeView1.Nodes[0];

                    // open the editor
                    OpenEditor();
                }
            }
#endif

            Text = "HSD DAT Browser - " + filePath;
        }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addRootFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var f = Tools.FileIO.OpenFile("HSD (*.dat;*.txg)|*.dat;*.txg");

            if (f != null)
            {
                if (f.ToLower().EndsWith(".dat"))
                {
                    var file = new HSDRawFile(f);

                    RawHSDFile.Roots.Add(file.Roots[0]);
                }
                if (f.ToLower().EndsWith(".txg"))
                {
                    var str = new HSDStruct();
                    str.SetData(System.IO.File.ReadAllBytes(f));

                    RawHSDFile.Roots.Add(new HSDRootNode()
                    {
                        Name = "TextureGraphic",
                        Data = new HSDRaw.Common.HSD_TEXGraphicBank()
                        {
                            _s = str
                        }
                    });
                }

                RefreshTree();
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 public void LoadFile(HSDRawFile file)
 {
     if (file != null)
     {
         LoadMnSlMap(file);
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FileName"></param>
        /// <param name="animation"></param>
        /// <param name="skeleton"></param>
        private void ExportAnimJoint(string FileName, SBAnimation animation, SBSkeleton skeleton)
        {
            HSDRawFile  file = new HSDRawFile();
            HSDRootNode root = new HSDRootNode();

            if (HSDSettings.RootName == "" || HSDSettings.RootName == null)
            {
                HSDSettings.RootName = System.IO.Path.GetFileNameWithoutExtension(FileName);
            }

            if (HSDSettings.RootName == "" || HSDSettings.RootName == null)
            {
                HSDSettings.RootName = animation.Name;
            }

            root.Name = HSDSettings.RootName;

            if (root.Name == null)
            {
                System.Windows.Forms.MessageBox.Show($"Warning, the root name does not end with \"_figatree\"\n{root.Name}");
            }

            file.Roots.Add(root);

            var joint = new HSD_AnimJoint();

            EncodeAnimJoint(skeleton.Bones[0], joint, animation);
            root.Data = joint;

            file.Save(FileName);
        }
Ejemplo n.º 10
0
        public static void DecompileAllPlDats(string path, string outputTxt)
        {
            using (StreamWriter w = new StreamWriter(new FileStream(outputTxt, FileMode.Create)))
                foreach (var f in Directory.GetFiles(path))
                {
                    if (Regex.IsMatch(Path.GetFileName(f), @"Pl..\.dat"))
                    {
                        HSDRawFile hsd = new HSDRawFile(f);

                        foreach (var r in hsd.Roots)
                        {
                            if (r.Data is SBM_FighterData pl)
                            {
                                w.WriteLine(r.Name);

                                ActionDecompiler d = new ActionDecompiler();

                                var sa = pl.FighterCommandTable.Commands;

                                int index = 0;
                                foreach (var v in sa)
                                {
                                    w.WriteLine(d.Decompile("Function_" + index++ + v.Name != null ? "_" + v.Name : "", v));
                                }
                            }
                        }
                    }
                }
        }
Ejemplo n.º 11
0
        public static void InstallMisc(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            data.MiscData = new HSDRaw.MEX.Misc.MEX_Misc();

            data.MiscData.GawColors = new HSDArrayAccessor <HSDRaw.MEX.Misc.MEX_GawColor>()
            {
                Array = new HSDRaw.MEX.Misc.MEX_GawColor[]
                {
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x00, 0x00, 0x00), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x6E, 0x00, 0x00), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x00, 0x00, 0x6E), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x00, 0x6E, 0x00), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                }
            };
        }
Ejemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void CopyMoveLogic(object sender, EventArgs args)
        {
            if (fighterListBox.SelectedItem is MEXFighter fighter)
            {
                var moveLogic = fighter.Functions.MoveLogic;

                if (moveLogic == null)
                {
                    MessageBox.Show("This MxDt file does not contains move logic", "Nothing to copy", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                var ftDataFile = MEX.ImageResource.GetFile(fighter.FighterDataPath);

                SBM_FighterData fighterData = null;

                if (ftDataFile != null)
                {
                    fighterData = new HSDRawFile(ftDataFile).Roots[0].Data as SBM_FighterData;
                }

                StringBuilder table = new StringBuilder();

                int index = 341;
                foreach (var m in moveLogic)
                {
                    table.AppendLine($"\t// State: {index} - " + (fighterData != null && m.AnimationID != -1 && fighterData.FighterCommandTable.Commands[m.AnimationID].Name != null ? System.Text.RegularExpressions.Regex.Replace(fighterData.FighterCommandTable.Commands[m.AnimationID].Name.Replace("_figatree", ""), @"Ply.*_Share_ACTION_", "") : "Animation: " + m.AnimationID.ToString("X")));
                    index++;
                    table.AppendLine(string.Format(
                                         "\t{{" +
                                         "\n\t\t{0, -12}// AnimationID" +
                                         "\n\t\t0x{1, -10}// StateFlags" +
                                         "\n\t\t0x{2, -10}// AttackID" +
                                         "\n\t\t0x{3, -10}// BitFlags" +
                                         "\n\t\t0x{4, -10}// AnimationCallback" +
                                         "\n\t\t0x{5, -10}// IASACallback" +
                                         "\n\t\t0x{6, -10}// PhysicsCallback" +
                                         "\n\t\t0x{7, -10}// CollisionCallback" +
                                         "\n\t\t0x{8, -10}// CameraCallback" +
                                         "\n\t}},",
                                         m.AnimationID + ",",
                                         m.StateFlags.ToString("X") + ",",
                                         m.AttackID.ToString("X") + ",",
                                         m.BitFlags.ToString("X") + ",",
                                         m.AnimationCallBack.ToString("X") + ",",
                                         m.IASACallBack.ToString("X") + ",",
                                         m.PhysicsCallback.ToString("X") + ",",
                                         m.CollisionCallback.ToString("X") + ",",
                                         m.CameraCallback.ToString("X") + ","
                                         ));
                }

                Clipboard.SetText(
                    @"__attribute__((used))
static struct MoveLogic move_logic[] = {
" + table.ToString() + @"}; ");

                MessageBox.Show("Move Logic Struct Copied to Clipboard", "Move Logic Copy");
            }
        }
Ejemplo n.º 13
0
        public static void RebuildFigaTree(string path, string outpath)
        {
            HSDRawFile file    = new HSDRawFile(path);
            var        oldTree = file.Roots[0].Data as HSD_FigaTree;

            HSDRawFile   newFile = new HSDRawFile();
            HSD_FigaTree newTree = new HSD_FigaTree();

            newTree.FrameCount = oldTree.FrameCount;
            newFile.Roots      = new List <HSDRootNode>();
            newFile.Roots.Add(new HSDRootNode()
            {
                Name = file.Roots[0].Name, Data = newTree
            });

            var newtracks = new List <FigaTreeNode>();

            foreach (var tracks in oldTree.Nodes)
            {
                var newt = new List <HSD_Track>();
                foreach (var track in tracks.Tracks)
                {
                    HSD_Track newtrack = new HSD_Track();
                    newtrack.FOBJ = FOBJFrameEncoder.EncodeFrames(track.GetKeys(), track.FOBJ.JointTrackType);
                    newt.Add(newtrack);
                }
                newtracks.Add(new FigaTreeNode()
                {
                    Tracks = newt
                });
            }
            newTree.Nodes = newtracks;

            newFile.Save(outpath);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Test for rebuilding pobjs from scratch
        /// </summary>
        /// <param name="path"></param>
        public static void RebuildPOBJs(string path)
        {
            HSDRawFile file = new HSDRawFile(path);

            var rootJOBJ = (HSD_JOBJ)(file.Roots[0].Data);

            file.Save(path + "_rebuilt.dat");
        }
Ejemplo n.º 15
0
        public static void RemoveImageNodes(string filePath)
        {
            HSDRawFile file = new HSDRawFile(filePath);

            file.Roots.RemoveAll(e => e.Name.EndsWith("_image"));

            file.Save(filePath + "_noImage");
        }
Ejemplo n.º 16
0
 public void OpenFile(Stream s)
 {
     this.OpenFileStream = new MemoryStream();
     s.CopyTo(this.OpenFileStream);
     s.Position = 0;
     RawHSDFile = new HSDRawFile();
     RawHSDFile.Open(s);
     RefreshTree();
 }
Ejemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lelf"></param>
        /// <param name="symbols"></param>
        /// <returns></returns>
        public static HSDRawFile BuildDatFile(LinkedELF lelf, IEnumerable <string> symbols = null)
        {
            Dictionary <SymbolData, HSDAccessor> symbolToAccessor = new Dictionary <SymbolData, HSDAccessor>();

            if (symbols == null)
            {
                symbols = lelf.AllSymbols.Select(e => e.Symbol);
            }

            // convert to accessors
            foreach (var d in lelf.AllSymbols)
            {
                symbolToAccessor.Add(d, new HSDAccessor()
                {
                    _s = new HSDStruct(d.Data)
                });
            }

            // check relocations
            foreach (var d in lelf.AllSymbols)
            {
                foreach (var r in d.Relocations)
                {
                    if (r.Type == RelocType.R_PPC_ADDR32)
                    {
                        symbolToAccessor[d]._s.SetReference((int)r.Offset, symbolToAccessor[r.Symbol]);
                    }
                    else
                    {
                        // TODO relocation error checking
                        //Console.WriteLine($"DAT Files don't support relocation type {r.Type}");
                        //return null;
                    }
                }
            }

            // generate dat file
            HSDRawFile file = new HSDRawFile();

            foreach (var v in symbols)
            {
                var data = lelf.AllSymbols.Find(e => e.Symbol.Equals(v));

                Console.WriteLine("Found " + v + ": " + !(data == null));

                if (data != null)
                {
                    file.Roots.Add(new HSDRootNode()
                    {
                        Name = v,
                        Data = symbolToAccessor[data]
                    });
                }
            }

            return(file);
        }
Ejemplo n.º 18
0
        public bool DoIt(string[] args)
        {
            if (args.Length >= 2)
            {
                var mapFile = args[1];

                var linkFile = (args.Length >= 3) ? args[2] : null;

                var      map  = new MapFile(mapFile);
                LinkFile link = null;
                if (linkFile != null)
                {
                    link = new LinkFile(linkFile);
                }

                var debug_symbol_table = new HSDStruct((map.Entries.Count + 1) * 0xC);
                int symbol_index       = 0;
                foreach (var e in map.Entries)
                {
                    debug_symbol_table.SetInt32(symbol_index * 0xC, (int)e.Start);
                    debug_symbol_table.SetInt32(symbol_index * 0xC + 4, (int)e.End);

                    if (link != null && link.TryGetAddressSymbol(e.Start, out string sym))
                    {
                        debug_symbol_table.SetString(symbol_index * 0xC + 8, sym, true);
                    }
                    else
                    if (!e.Symbol.StartsWith("zz_"))
                    {
                        debug_symbol_table.SetString(symbol_index * 0xC + 8, e.Symbol, true);
                    }
                    symbol_index++;
                }

                var function = new HSDAccessor()
                {
                    _s = new HSDStruct(0x10)
                };
                function._s.SetInt32(0, map.Entries.Count);
                function._s.SetReferenceStruct(0x04, debug_symbol_table);

                HSDRawFile f = new HSDRawFile();
                f.Roots.Add(new HSDRootNode()
                {
                    Data = function,
                    Name = "mexDebug"
                });

                f.Save("MxDb.dat");


                return(true);
            }

            return(false);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Generates an Eff file for Fighter & Kirby
        /// Adds entries for effects to mexData
        /// Updates ids for Fighter Mex Entry
        /// </summary>
        /// <param name="pack"></param>
        /// <param name="fighter"></param>
        /// <param name="editor"></param>
        /// <returns>Dictionary to maps old id values to new values</returns>
        private void GenerateEffectFile(ZipFile pack, MEXFighterEntry fighter)
        {
            Console.WriteLine($"Generating Effect File...");

            // Generate information---------------------------------------------
            string charID               = Regex.Match(fighter.FighterDataPath, @"(?<=Pl)..").Value;
            var    root                 = Path.GetDirectoryName(MainForm.Instance.FilePath);
            var    effectFileName       = $"Ef{charID}Data.dat";
            var    effectOutputFilePath = Path.Combine(root, effectFileName);
            var    symbol               = $"eff{fighter.NameText}DataTable";


            // Generate Effect File-------------------------------------------
            var models = pack.Where(e => Regex.IsMatch(e.FileName, @"Effect/effect\d\d.*.dat")).ToArray();
            var ptcl   = pack["Effect/effect.ptcl"];
            var texg   = pack["Effect/effect.texg"];

            SBM_EffectTable effTable = new SBM_EffectTable();

            if (ptcl != null && texg != null)
            {
                effTable._s.SetReferenceStruct(0x00, new HSDStruct(GetBytes(ptcl)));
                effTable._s.SetReferenceStruct(0x04, new HSDStruct(GetBytes(texg)));
            }

            SBM_EffectModel[] effModels = new SBM_EffectModel[models.Length];
            for (int i = 0; i < models.Length; i++)
            {
                effModels[i]    = new SBM_EffectModel();
                effModels[i]._s = new HSDRawFile(GetBytes(models[i])).Roots[0].Data._s;
            }
            effTable.Models = effModels;

            // Save File---------------------------------------------

            var effFile = new HSDRawFile();

            effFile.Roots.Add(new HSDRootNode()
            {
                Name = symbol,
                Data = effTable
            });

            editedFiles.Add(new Tuple <HSDRawFile, string, bool>(effFile, effectOutputFilePath, true));


            // Add Effect Entries-------------------------------------------
            MEXEffectEntry effectFiles = new MEXEffectEntry();

            effectFiles.FileName = effectFileName;
            effectFiles.Symbol   = symbol;
            var effectID = editor.EffectControl.AddMEXEffectFile(effectFiles);

            fighter.EffectIndex = effectID;
            Console.WriteLine("Effect ID:" + effectID);
        }
Ejemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        private void OpenFile(string filePath)
        {
            FilePath = filePath;

            RawHSDFile = new HSDRawFile();
            RawHSDFile.Open(filePath);
            RefreshTree();

            Text = "HSD DAT Browser - " + filePath;
        }
Ejemplo n.º 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FilePath"></param>
        private void LoadGm(string FilePath)
        {
            var gmDat = new HSDRawFile(FilePath);

            // validate
            if (gmDat.Roots.Count == 0)
            {
                return;
            }
            var name = gmDat.Roots[0].Name.Replace("ftDemoResultMotionFile", "");

            if (name != FighterName)
            {
                if (MessageBox.Show($"Import animation for {name} instead of {FighterName}?", "Warning", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }
            }

            lbResult.BeginUpdate();
            using (BinaryReader r = new BinaryReader(new MemoryStream(gmDat.Roots[0].Data._s.GetData())))
            {
                var winsubs = PlayerData.DemoActionTable.Commands;

                foreach (var v in winsubs)
                {
                    if (v.Name != null && !AnimationLoaded(v.Name))
                    {
                        Console.WriteLine(v.Name + " " + v.AnimationOffset.ToString("X") + " " + v.AnimationSize.ToString("X"));

                        r.BaseStream.Position = v.AnimationOffset;
                        var data = r.ReadBytes(v.AnimationSize);

                        try
                        {
                            HSDRawFile file = new HSDRawFile(data);

                            //if (file.Roots[0].Name != v.Name)
                            //    continue;

                            ResultAnimations.Add(new Animation()
                            {
                                Name = v.Name, Data = data
                            });
                        } catch (Exception)
                        {
                        }
                    }
                }
            }
            lbResult.EndUpdate();

            ResultLoaded = true;
        }
Ejemplo n.º 22
0
        public static void Compare(string oldpath, string newpath)
        {
            var f1 = new HSDRawFile(oldpath);
            var f2 = new HSDRawFile(newpath);

            Console.WriteLine(f1.Roots.Count + " " + f2.Roots.Count);

            for (int i = 0; i < f1.Roots.Count; i++)
            {
                CompareNode(f1.Roots[i].Data._s, f2.Roots[i].Data._s, new HashSet <HSDStruct>(), $"{(i * 4).ToString("X8")}->");
            }
        }
Ejemplo n.º 23
0
        public override void LoadFromFile(string FileName)
        {
            if (System.IO.File.Exists(FileName.Replace(".dat", ".jcv")))
            {
                IO.Formats.IO_8MOT.Settings.JVCPath = FileName.Replace(".dat", ".jcv");
            }

            HSDFile = new HSDRawFile(FileName);
            RefreshSkeleton();
            CreateMesh();
            RefreshRendering();
        }
Ejemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filePath"></param>
        private void LoadMnSlMap(HSDRawFile hsd)
        {
            if (StageMenuFile != null)
            {
                return;
            }

            var org = hsd["MnSelectStageDataTable"];
            var mex = hsd["mexMapData"];

            if (org != null && mex == null)
            {
                MessageBox.Show("MexMapData symbol not found. One will now be generated", "Symbol Not Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                // load and convert data from vanilla
                MexMapGenerator.LoadIconDataFromVanilla(org.Data as SBM_MnSelectStageDataTable, Icons);

                // generate mex data node
                hsd.Roots.Add(new HSDRootNode()
                {
                    Name = "mexMapData",
                    Data = MexMapGenerator.GenerateMexMap(org.Data as SBM_MnSelectStageDataTable, Icons)
                });

                mex = hsd["mexMapData"];
            }

            if (org != null && mex != null)
            {
                var stage  = org.Data as SBM_MnSelectStageDataTable;
                var mexMap = mex.Data as MEX_mexMapData;

                //StageMenuFilePath = filePath;
                StageMenuFile = hsd;

                // Load Data from Mex Symbol
                MexMapGenerator.LoadIconDataFromSymbol(mexMap, Icons);

                // Load Dummy Icon Model
                IconJOBJManager.RefreshRendering = true;
                var icon = HSDAccessor.DeepClone <HSD_JOBJ>(mexMap.IconModel);
                IconJOBJManager.SetJOBJ(icon);

                // Load Dummy Stage Name Model
                StageNameJOBJManager.RefreshRendering = true;
                var name = HSDAccessor.DeepClone <HSD_JOBJ>(stage.StageNameModel);
                StageNameJOBJManager.SetJOBJ(name);
                StageNameJOBJManager.SetAnimJoint(stage.StageNameAnimJoint);
                StageNameJOBJManager.Frame = 10;

                Enabled = true;
            }
        }
Ejemplo n.º 25
0
        public static void Compare(string oldpath, string newpath)
        {
            var f1 = new HSDRawFile(oldpath);
            var f2 = new HSDRawFile(newpath);

            var ss1 = f1.Roots[0].Data._s.GetSubStructs();
            var ss2 = f2.Roots[0].Data._s.GetSubStructs();

            Console.WriteLine(f1.Roots[0].Data._s.GetSubStructs().Count + " " + f2.Roots[0].Data._s.GetSubStructs().Count);

            CompareNode(f1.Roots[0].Data._s, f2.Roots[0].Data._s, new HashSet <HSDStruct>());
        }
Ejemplo n.º 26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ftdat"></param>
        /// <param name="ajdat"></param>
        /// <param name="editAnim"></param>
        public static void EditFighterAnimations(string ftdat, string ajdat, EditAnimation editAnim)
        {
            FighterAJManager manager = new FighterAJManager(File.ReadAllBytes(ajdat));

            foreach (var symbol in manager.GetAnimationSymbols())
            {
                if (symbol.Contains("Taro"))
                {
                    continue;
                }

                var ftFile = new HSDRawFile(manager.GetAnimationData(symbol));

                if (ftFile[symbol] != null)
                {
                    var ft = ftFile[symbol].Data as HSD_FigaTree;
                    editAnim(ft, symbol);
                    ftFile[symbol].Data = ft;

                    using (MemoryStream stream = new MemoryStream())
                    {
                        ftFile.Save(stream);
                        manager.SetAnimation(symbol, stream.ToArray());
                    }
                }
            }

            var newAJFile = manager.RebuildAJFile(manager.GetAnimationSymbols().ToArray(), true);

            HSDRawFile ftfile = new HSDRawFile(ftdat);

            if (ftfile.Roots[0].Data is SBM_FighterData data)
            {
                var sa = data.FighterActionTable.Commands;

                foreach (var action in sa)
                {
                    if (action.SymbolName != null && !string.IsNullOrEmpty(action.SymbolName.Value))
                    {
                        var sizeOffset = manager.GetOffsetSize(action.SymbolName.Value);
                        action.AnimationOffset = sizeOffset.Item1;
                        action.AnimationSize   = sizeOffset.Item2;
                    }
                }

                data.FighterActionTable.Commands = sa;

                ftfile.TrimData();
                ftfile.Save(ftdat);
                File.WriteAllBytes(ajdat, newAJFile);
            }
        }
Ejemplo n.º 27
0
 /// <summary>
 ///
 /// </summary>
 private static void ExtractDataFromResource(HSDRawFile resourceFile, HSDAccessor acc)
 {
     foreach (var p in acc.GetType().GetProperties())
     {
         var sym = resourceFile[p.Name];
         if (sym != null)
         {
             var i = Activator.CreateInstance(p.PropertyType);
             ((HSDAccessor)i)._s = sym.Data._s;
             p.SetValue(acc, i);
         }
     }
 }
Ejemplo n.º 28
0
 /// <summary>
 ///
 /// </summary>
 private void SaveAnimation()
 {
     if (actionList.SelectedItem is Action action)
     {
         HSDRawFile f = new HSDRawFile();
         f.Roots.Add(new HSDRootNode()
         {
             Name = action.Symbol,
             Data = JointManager.Animation.ToFigaTree()
         });
         var tempFileName = Path.GetTempFileName();
         f.Save(tempFileName);
         SymbolToAnimation[action.Symbol] = File.ReadAllBytes(tempFileName);
         File.Delete(tempFileName);
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public bool DoIt(string[] args)
        {
            if (args.Length >= 3)
            {
                // parse args
                var targetAnimFile = Path.GetFullPath(args[1]);
                var destAnimFile   = Path.GetFullPath(args[2]);

                // retarget animation
                HSDRawFile inputAnim = new HSDRawFile(targetAnimFile);

                var targetTree = inputAnim.Roots[0].Data as HSD_FigaTree;

                List <FigaTreeNode> newNodes = targetTree.Nodes;

                var keydecrease = 0;

                foreach (var n in newNodes)
                {
                    foreach (var t in n.Tracks)
                    {
                        var fobj = t.ToFOBJ();
                        var keys = fobj.GetDecodedKeys();

                        if (keys.Count > targetTree.FrameCount * 0.8f)
                        {
                            var before = keys.Count;
                            keys = Tools.LineSimplification.Simplify(keys, 0.025f);
                            fobj.SetKeys(keys, fobj.JointTrackType);
                            t.FromFOBJ(fobj);

                            keydecrease += before - keys.Count;
                        }
                    }
                }

                Console.WriteLine("Optimized " + keydecrease + " removed");

                targetTree.Nodes = newNodes;

                inputAnim.Save(destAnimFile);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 30
0
        /// <summary>
        ///
        /// </summary>
        public void CloseFile()
        {
            IconJOBJManager.CleanupRendering();
            StageNameJOBJManager.CleanupRendering();

            StageMenuFile = null;

            /*if (Icons != null)
             *  foreach (var v in Icons)
             *  {
             *      v.Joint = null;
             *      v.Animation = null;
             *      v.NameTOBJ = null;
             *      v.IconTOBJ = null;
             *  }*/

            Enabled = false;
        }