/// <summary>
        ///
        /// </summary>
        private void UpdateAnimationWithFSMs()
        {
            // load backup animation
            var tempanim = new JointAnimManager();

            tempanim.FromFigaTree(BackupAnim.ToFigaTree());
            var backup = BackupAnim;

            // apply fsms to backup animation
            tempanim.ApplyFSMs(FrameSpeedModifiers);

            // load edited anim
            LoadFigaTree(SelectedAction.Symbol, tempanim.ToFigaTree());
            BackupAnim = backup;

            // refresh fsm display tips
            UpdateFrameTips();
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void compressAllAnimationsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (AJManager == null)
            {
                return;
            }

            HashSet <string> edited = new HashSet <string>();
            int oldSize             = 0;
            int newSize             = 0;

            foreach (var a in AllActions)
            {
                if (string.IsNullOrEmpty(a.Symbol) || edited.Contains(a.Symbol))
                {
                    continue;
                }

                var anim = AJManager.GetAnimationData(a.Symbol);
                if (anim != null)
                {
                    JointAnimManager ja = new JointAnimManager();
                    var animfile        = new HSDRawFile(anim);
                    ja.FromFigaTree(animfile.Roots[0].Data as HSD_FigaTree);
                    //ja.Optimize(JointManager.GetJOBJ(0), 0.01f);
                    animfile.Roots[0].Data = ja.ToFigaTree(0.01f);
                    using (MemoryStream s = new MemoryStream())
                    {
                        animfile.Save(s);
                        var newfile = s.ToArray();
                        oldSize += anim.Length;
                        newSize += newfile.Length;
                        AJManager.SetAnimation(a.Symbol, newfile);
                    }
                }
                edited.Add(a.Symbol);
            }

            Console.WriteLine($"{oldSize.ToString("X")} => {newSize.ToString("X")}");
            Console.WriteLine($"Saved {(oldSize - newSize).ToString("X")} bytes");
        }
        /// <summary>
        ///
        /// </summary>
        private void SaveAnimationChanges()
        {
            if (actionList.SelectedItem is Action action)
            {
                HSDRawFile f = new HSDRawFile();

                f.Roots.Add(new HSDRootNode()
                {
                    Name = action.Symbol,
                    Data = JointManager.Animation.ToFigaTree()
                });

                using (MemoryStream stream = new MemoryStream())
                {
                    f.Save(stream);
                    AJManager.SetAnimation(action.Symbol, stream.ToArray());
                }

                BackupAnim.FromFigaTree(JointManager.Animation.ToFigaTree());
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void LoadFigaTree(string treeSymbol, HSD_FigaTree tree)
        {
            // clear animation
            JointManager.SetFigaTree(null);
            ThrowDummyManager.SetFigaTree(null);

            // create new action
            var name = new Action()
            {
                Symbol = treeSymbol
            }.ToString();

            // load figatree to manager and anim editor
            JointManager.SetFigaTree(tree);
            _animEditor.SetJoint(JointManager.GetJOBJ(0), JointManager.Animation);

            // set backup anim
            BackupAnim = new JointAnimManager();
            BackupAnim.FromFigaTree(tree);

            // set frame
            viewport.MaxFrame = tree.FrameCount;


            // enable shield display
            if (FighterData != null && name.Equals("Guard"))
            {
                DisplayShieldSize = FighterData.Attributes.ShieldSize / 2;
            }


            // load throw dummy for thrown animations
            if (name.Contains("Throw") && !name.Contains("Taro"))
            {
                // find thrown anim
                Action throwAction = null;
                foreach (Action a in actionList.Items)
                {
                    if (a.Symbol != null &&
                        a.Symbol.Contains("Taro") &&
                        a.Symbol.Contains(name) &&
                        !a.Symbol.Equals(treeSymbol))
                    {
                        throwAction = a;
                        break;
                    }
                }

                // if throw animation is found
                if (throwAction != null &&
                    throwAction.Symbol != null)
                {
                    var throwData = AJManager.GetAnimationData(throwAction.Symbol);

                    if (throwData != null)
                    {
                        // load throw animation
                        var tanim = new HSDRawFile(throwData);
                        if (tanim.Roots[0].Data is HSD_FigaTree tree2)
                        {
                            ThrowDummyManager.SetFigaTree(tree2);
                            if (ThrowDummyLookupTable.Count > 0)
                            {
                                ThrowDummyManager.Animation.EnableBoneLookup = true;
                                ThrowDummyManager.Animation.BoneLookup       = ThrowDummyLookupTable;
                            }
                        }
                    }
                }
            }
        }