示例#1
0
        public void ErrorCheck()
        {
            if (BFRESRender != null)
            {
                List <Errors> Errors = new List <Errors>();
                foreach (FMDL model in BFRESRender.models)
                {
                    foreach (FSHP shp in model.shapes)
                    {
                        if (!IsWiiU)
                        {
                            Syroot.NintenTools.NSW.Bfres.VertexBuffer vtx  = shp.VertexBuffer;
                            Syroot.NintenTools.NSW.Bfres.Material     mat  = shp.GetMaterial().Material;
                            Syroot.NintenTools.NSW.Bfres.ShaderAssign shdr = mat.ShaderAssign;

                            for (int att = 0; att < vtx.Attributes.Count; att++)
                            {
                                if (!shdr.AttribAssigns.Contains(vtx.Attributes[att].Name))
                                {
                                    MessageBox.Show($"Error! Attribute {vtx.Attributes[att].Name} is unlinked!");
                                }
                            }
                            for (int att = 0; att < mat.TextureRefs.Count; att++)
                            {
                                if (!shdr.SamplerAssigns.Contains(mat.SamplerDict.GetKey(att))) //mat.SamplerDict[att]
                                {
                                    MessageBox.Show($"Error! Sampler {mat.SamplerDict.GetKey(att)} is unlinked!");
                                }
                            }
                        }
                        else
                        {
                            Syroot.NintenTools.Bfres.VertexBuffer vtx  = shp.VertexBufferU;
                            Syroot.NintenTools.Bfres.Material     mat  = shp.GetMaterial().MaterialU;
                            Syroot.NintenTools.Bfres.ShaderAssign shdr = mat.ShaderAssign;

                            for (int att = 0; att < vtx.Attributes.Count; att++)
                            {
                                if (!shdr.AttribAssigns.ContainsKey(vtx.Attributes[att].Name))
                                {
                                    MessageBox.Show($"Error! Attribute {vtx.Attributes[att].Name} is unlinked!");
                                }
                            }
                            for (int att = 0; att < mat.TextureRefs.Count; att++)
                            {
                                string samp = "";
                                mat.Samplers.TryGetKey(mat.Samplers[att], out samp);
                                if (!shdr.SamplerAssigns.ContainsKey(samp)) //mat.SamplerDict[att]
                                {
                                    MessageBox.Show($"Error! Sampler {samp} is unlinked!");
                                }
                            }
                        }
                    }
                }
                //   ErrorList errorList = new ErrorList();
                //   errorList.LoadList(Errors);
                //    errorList.Show();
            }
        }
示例#2
0
        public int GetStaticKey(ResNX.ShaderAssign ShaderAssign)
        {
            if (bfshaFile.ShaderModelDict.ContainsKey(ShaderAssign.ShadingModelName))
            {
                int ModelIndex = bfshaFile.ShaderModelDict.IndexOf(ShaderAssign.ShadingModelName);

                for (int option = 0; option < ShaderAssign.ShaderOptions.Count; option++)
                {
                    int OptionIndex  = bfshaFile.ShaderModels[ModelIndex].StaticOptionDict.IndexOf(ShaderAssign.ShaderOptions[option]);
                    var OptionStatic = bfshaFile.ShaderModels[ModelIndex].StaticOptions[OptionIndex];

                    int ChoiceIndex = OptionStatic.ChoiceDict.IndexOf(ShaderAssign.ShaderOptions[option]);

                    return(bfshaFile.ShaderModels[ModelIndex].GetStaticKey(OptionIndex, ChoiceIndex));
                }
            }
            else
            {
                throw new Exception("Model not found in bfsha!");
            }

            return(-1);
        }