예제 #1
0
파일: FVIS.cs 프로젝트: nnn1590/Smash-Forge
            public void ReadVIS(BFRES.MTA mta, Syroot.NintenTools.NSW.Bfres.VisibilityAnim vis)
            {
                mta.Text       = vis.Name;
                mta.FrameCount = (uint)vis.FrameCount;

                int boneindx = 0;

                if (vis.Names != null)
                {
                    foreach (string nm in vis.Names) //Loop through every bone. Not all have base and curve data
                    {
                        MatAnimEntry bone = new MatAnimEntry();
                        bone.Text = vis.Names[boneindx];

                        if (vis.BaseDataList == null)
                        {
                            vis.BaseDataList = new bool[0];
                        }

                        if (boneindx < vis.BaseDataList.Length)
                        {
                            MatAnimData md = new MatAnimData();

                            bool bas = vis.BaseDataList[boneindx];
                            md.VIS_State = bas;
                            md.Frame     = 0;

                            bone.matCurves.Add(md);
                        }


                        if (vis.Curves.Count != 0)
                        {
                            if (boneindx < vis.Curves.Count)
                            {
                                Syroot.NintenTools.NSW.Bfres.AnimCurve cr = vis.Curves[boneindx];


                                int frm = 0;
                                foreach (bool bn in cr.KeyStepBoolData)
                                {
                                    BFRES.MatAnimData md = new BFRES.MatAnimData();
                                    md.Frame     = (int)cr.Frames[frm];
                                    md.VIS_State = bn;

                                    bone.matCurves.Add(md);
                                    frm++;
                                }
                            }
                        }
                        mta.matEntries.Add(bone);

                        boneindx++;
                    }
                }
            }
예제 #2
0
            public PerShapeAnim(BFRES.MTA mta, ShapeAnim vis)
            {
                mta.Text             = vis.Name;
                mta.ImageKey         = "mesh";
                mta.SelectedImageKey = "mesh";

                mta.FrameCount = (uint)vis.FrameCount;


                foreach (VertexShapeAnim vtxanim in vis.VertexShapeAnims)
                {
                    BFRES.MatAnimEntry mat = new BFRES.MatAnimEntry();

                    mat.ImageKey         = "bone";
                    mat.SelectedImageKey = "bone";


                    //First set the data then iterpolate
                    mat.Text = vtxanim.Name;
                    foreach (AnimCurve cr in vtxanim.Curves)
                    {
                        mat.Interpolate(cr);
                    }

                    for (int Frame = 0; Frame < vis.FrameCount; Frame++)
                    {
                        foreach (BFRES.MatAnimData track in mat.matCurves)
                        {
                            BFRES.AnimKey left  = track.GetLeft(Frame);
                            BFRES.AnimKey right = track.GetRight(Frame);



                            track.Value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);
                        }
                    }
                    mta.matEntries.Add(mat);
                }
            }
예제 #3
0
            public PerMatAnim(BFRES.MTA mta, MaterialAnim vis)
            {
                mta.Text = vis.Name;

                mta.FrameCount = (uint)vis.FrameCount;


                if (vis.TextureNames != null)
                {
                    foreach (string tex in vis.TextureNames)
                    {
                        mta.Pat0.Add(tex);
                    }
                }

                foreach (MaterialAnimData matanim in vis.MaterialAnimDataList)
                {
                    BFRES.MatAnimEntry mat = new BFRES.MatAnimEntry();

                    mat.Text = matanim.Name;



                    if (matanim.Curves.Count == 0)
                    {
                        int CurTex = 0;
                        foreach (TexturePatternAnimInfo inf in matanim.TexturePatternAnimInfos)
                        {
                            if (vis.TextureNames != null)
                            {
                                BFRES.MatAnimData md = new BFRES.MatAnimData();


                                //Switch doesn't have base values? I can't find any like wii u did so i'll just have this look though each texture map.
                                //Some have multiple maps but one texture (Yoshi in Odyssey) so this checks the texture count
                                if (CurTex + 1 <= vis.TextureNames.Count)
                                {
                                    md.Pat0Tex = mta.Pat0[CurTex];
                                }
                                else
                                {
                                    md.Pat0Tex = mta.Pat0[0];
                                }

                                md.SamplerName = inf.Name;
                                md.Frame       = 0;

                                mat.matCurves.Add(md);
                            }
                            CurTex++;
                        }
                    }

                    int CurCurve = 0;
                    foreach (AnimCurve cr in matanim.Curves)
                    {
                        for (int i = 0; i < (ushort)cr.Frames.Length; i++)
                        {
                            MatAnimData md = new MatAnimData();

                            foreach (TexturePatternAnimInfo inf in matanim.TexturePatternAnimInfos)
                            {
                                if (inf.CurveIndex == CurCurve)
                                {
                                    md.SamplerName = inf.Name;
                                }
                            }

                            //Set pat0 data if texture list exists
                            if (vis.TextureNames != null)
                            {
                                if (cr.KeyType == AnimCurveKeyType.SByte)
                                {
                                    md.CurveIndex = CurCurve;

                                    if (cr.Scale != 0)
                                    {
                                        int   test = (int)cr.Keys[i, 0];
                                        float key  = cr.Offset + test * cr.Scale;
                                        md.Pat0Tex = (mta.Pat0[(int)key]);
                                        md.Frame   = (int)cr.Frames[i];
                                    }
                                    else
                                    {
                                        int test = (int)cr.Keys[i, 0];
                                        int key  = cr.Offset + test;
                                        md.Pat0Tex = (mta.Pat0[(int)key]);
                                        md.Frame   = (int)cr.Frames[i];
                                    }
                                }
                            }
                            mat.matCurves.Add(md);
                        }
                        CurCurve++;
                    }

                    mta.matEntries.Add(mat);
                }
            }
예제 #4
0
            public BFRES_FVTX(BFRES.MTA mta, TexPatternAnim tex, ResFile b)
            {
                mta.Text = tex.Name;

                mta.FrameCount = (uint)tex.FrameCount;


                if (tex.TextureRefs != null || tex.TextureRefNames != null)
                {
                    if (b.Version >= 0x03040000)
                    {
                        foreach (var tx in tex.TextureRefs)
                        {
                            mta.Pat0.Add(tx.Key);
                        }
                    }
                    else
                    {
                        foreach (var tx in tex.TextureRefNames)
                        {
                            mta.Pat0.Add(tx.Name);
                            //Console.WriteLine(tx.Name);
                        }
                    }
                }

                foreach (TexPatternMatAnim matanim in tex.TexPatternMatAnims)
                {
                    BFRES.MatAnimEntry mat = new BFRES.MatAnimEntry();

                    mat.Text = matanim.Name;
                    //Console.WriteLine($"MatAnim = {mat.Text}");
                    //Console.WriteLine($"Curve Count = {matanim.Curves.Count}");

                    if (matanim.Curves.Count == 0)
                    {
                        int CurTex = 0;
                        foreach (PatternAnimInfo inf in matanim.PatternAnimInfos)
                        {
                            if (tex.TextureRefs != null || tex.TextureRefNames != null)
                            {
                                BFRES.MatAnimData md = new BFRES.MatAnimData();

                                md.Pat0Tex     = mta.Pat0[CurTex];
                                md.SamplerName = inf.Name;
                                md.Frame       = 0;

                                mat.matCurves.Add(md);
                            }
                            CurTex++;
                        }
                    }

                    int CurCurve = 0;
                    foreach (AnimCurve cr in matanim.Curves)
                    {
                        for (int i = 0; i < (ushort)cr.Frames.Length; i++)
                        {
                            BFRES.MatAnimData md = new BFRES.MatAnimData();

                            foreach (PatternAnimInfo inf in matanim.PatternAnimInfos)
                            {
                                if (inf.CurveIndex == CurCurve)
                                {
                                    md.SamplerName = inf.Name;
                                }
                            }

                            if (tex.TextureRefs != null || tex.TextureRefNames != null)
                            {
                                if (cr.KeyType == AnimCurveKeyType.SByte)
                                {
                                    md.CurveIndex = CurCurve;

                                    if (cr.Scale != 0)
                                    {
                                        int   test = (int)cr.Keys[i, 0];
                                        float key  = cr.Offset + test * cr.Scale;
                                        md.Pat0Tex = (mta.Pat0[(int)key]);
                                        md.Frame   = (int)cr.Frames[i];
                                    }
                                    else
                                    {
                                        int test = (int)cr.Keys[i, 0];
                                        int key  = cr.Offset + test;
                                        md.Pat0Tex = (mta.Pat0[(int)key]);
                                        md.Frame   = (int)cr.Frames[i];
                                        //Console.WriteLine($"{md.Frame} {md.Pat0Tex}");
                                    }
                                }
                            }
                            mat.matCurves.Add(md);
                        }
                        CurCurve++;
                    }

                    foreach (BFRES.MatAnimData md in mat.matCurves)
                    {
                        //Console.WriteLine($"At frame {md.Frame} show {md.Pat0Tex} {md.SamplerName}");
                    }

                    mta.matEntries.Add(mat);
                }
            }