コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        public void SaveStockNode()
        {
            // set meta data
            StockNode.Reserved = (short)ReservedItems.Length;
            StockNode.Stride   = (short)Items.Length;

            List <FOBJKey>  keys  = new List <FOBJKey>();
            List <HSD_TOBJ> tobjs = new List <HSD_TOBJ>();

            // reserved
            for (int i = 0; i < ReservedItems.Length; i++)
            {
                if (ReservedItems[i].TOBJS.Length > 0)
                {
                    keys.Add(new FOBJKey()
                    {
                        Frame = i, InterpolationType = GXInterpolationType.HSD_A_OP_CON, Value = tobjs.Count
                    });
                    tobjs.Add(ReservedItems[i].TOBJS[0].TOBJ);
                }
            }

            // get fighter stock icons
            for (int i = 0; i < Items.Length; i++)
            {
                for (int j = 0; j < Items[i].TOBJS.Length; j++)
                {
                    keys.Add(new FOBJKey()
                    {
                        Frame = ReservedItems.Length + j * Items.Length + i, InterpolationType = GXInterpolationType.HSD_A_OP_CON, Value = tobjs.Count
                    });
                    tobjs.Add(Items[i].TOBJS[j].TOBJ);
                }
            }

            // order keys
            keys = keys.OrderBy(e => e.Frame).ToList();

            // generate new tex anim
            var newTexAnim = new HSD_TexAnim();

            newTexAnim.AnimationObject          = new HSD_AOBJ();
            newTexAnim.AnimationObject.FObjDesc = new HSD_FOBJDesc();
            newTexAnim.AnimationObject.FObjDesc.SetKeys(keys, (byte)TexTrackType.HSD_A_T_TIMG);
            newTexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc();
            newTexAnim.AnimationObject.FObjDesc.Next.SetKeys(keys, (byte)TexTrackType.HSD_A_T_TCLT);

            newTexAnim.FromTOBJs(tobjs, false);
            newTexAnim.Optimize();

            StockNode.MatAnimJoint = new HSD_MatAnimJoint();
            StockNode.MatAnimJoint.MaterialAnimation = new HSD_MatAnim();
            StockNode.MatAnimJoint.MaterialAnimation.TextureAnimation = newTexAnim;

            // done
            MessageBox.Show("Stock Icon Symbol has been rebuilt");
        }
コード例 #2
0
ファイル: MexStockIconTool.cs プロジェクト: youdontown/HSDLib
        /// <summary>
        ///
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static MEX_Stock GenerateStockIconNodeFromVanilla(HSD_TexAnim texanim)
        {
            // extract tex anim assets
            var         tobjs  = texanim.ToTOBJs();
            var         keys   = texanim.AnimationObject.FObjDesc.GetDecodedKeys();
            FOBJ_Player player = new FOBJ_Player();

            player.Keys = keys;


            // generate stock node
            var stockNode = new MEX_Stock();

            stockNode.Reserved = 10;
            stockNode.Stride   = 26;

            var newTobjs = new List <HSD_TOBJ>();
            var newKeys  = new List <FOBJKey>();

            // get hardcoded images

            /*
             *  0 - blank
             * 1 - smash ball
             * 2 - master hand
             * 3 - crazy hand
             * 4 - target
             * 5 - giga bowser
             * 6 - sandbag
             * 7 - red dot
             * 8 - furby
             */

            int[] hardcoded = new[] { 250, 26, 27, 28, 57, 58, 59, 185, 185 };

            for (int i = 0; i < hardcoded.Length; i++)
            {
                newKeys.Add(new FOBJKey()
                {
                    Frame = i, InterpolationType = GXInterpolationType.HSD_A_OP_CON, Value = newTobjs.Count
                });
                newTobjs.Add(tobjs[(int)player.GetValue(hardcoded[i])]);
            }

            // get fighter stock icons
            for (int i = 0; i < 27; i++)
            {
                int color = 0;
                while (true)
                {
                    var key = keys.Find(e => e.Frame == color * 30 + (i == 26 ? 29 : i));

                    if (key != null)
                    {
                        newKeys.Add(new FOBJKey()
                        {
                            Frame = 10 + color * 26 + i, InterpolationType = GXInterpolationType.HSD_A_OP_CON, Value = newTobjs.Count
                        });
                        newTobjs.Add(tobjs[(int)key.Value]);
                        color++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            // order keys
            newKeys = newKeys.OrderBy(e => e.Frame).ToList();
            foreach (var k in newKeys)
            {
                Console.WriteLine(k.Frame + " " + k.Value);
            }

            // generate new tex anim
            var newTexAnim = new HSD_TexAnim();

            newTexAnim.AnimationObject          = new HSD_AOBJ();
            newTexAnim.AnimationObject.FObjDesc = new HSD_FOBJDesc();
            newTexAnim.AnimationObject.FObjDesc.SetKeys(newKeys, (byte)TexTrackType.HSD_A_T_TIMG);
            newTexAnim.AnimationObject.FObjDesc.Next = new HSD_FOBJDesc();
            newTexAnim.AnimationObject.FObjDesc.Next.SetKeys(newKeys, (byte)TexTrackType.HSD_A_T_TCLT);

            newTexAnim.FromTOBJs(newTobjs, false);

            stockNode.MatAnimJoint = new HSD_MatAnimJoint();
            stockNode.MatAnimJoint.MaterialAnimation = new HSD_MatAnim();
            stockNode.MatAnimJoint.MaterialAnimation.TextureAnimation = newTexAnim;

            return(stockNode);
        }