Пример #1
0
            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 BFRES_MTA(MaterialAnim vis)
        {
            ImageKey         = "image";
            SelectedImageKey = "image";


            Text = vis.Name;

            FrameCount = (uint)vis.FrameCount;

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

                FMAANode matnode = new FMAANode(matanim);

                mat.Text = matanim.Name;

                for (int Frame = 0; Frame < vis.FrameCount; Frame++)
                {
                    int CurTrack = 0;
                    foreach (FMAATrack track in matnode.tracks)
                    {
                        MatAnimData md = new MatAnimData();

                        float value;

                        if (matanim.Curves[CurTrack].CurveType == AnimCurveType.Cubic)
                        {
                            FMAAKey left  = track.GetLeft(Frame);
                            FMAAKey right = track.GetRight(Frame);

                            value = Animation.Hermite(Frame, left.frame, right.frame, 0, 0, left.unk1, right.unk1);

                            md.keys.Add(value);
                        }


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

                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);
                }
            }