コード例 #1
0
            private void FrameBfres()
            {
                BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));

                bfresEditor.FrameCamera(MainCostume.BFRESRender);

                MainCostume = null;
            }
コード例 #2
0
        public static Model SetModel(FMDL fmdl)
        {
            Model model = new Model();

            model.Name = fmdl.Text;
            model.Path = "";

            model.Shapes        = new List <Shape>();
            model.VertexBuffers = new List <VertexBuffer>();
            model.Materials     = new List <Material>();
            model.UserData      = new List <UserData>();
            model.Skeleton      = new Skeleton();
            model.Skeleton      = fmdl.Skeleton.node.Skeleton;
            model.ShapeDict     = new ResDict();
            model.MaterialDict  = new ResDict();
            model.UserDataDict  = new ResDict();
            model.UserData      = fmdl.Model.UserData;
            model.UserDataDict  = fmdl.Model.UserDataDict;

            if (model.Skeleton.InverseModelMatrices == null)
            {
                model.Skeleton.InverseModelMatrices = new List <Syroot.Maths.Matrix3x4>();
            }
            if (model.Skeleton.MatrixToBoneList == null)
            {
                model.Skeleton.MatrixToBoneList = new List <ushort>();
            }

            fmdl.Skeleton.CalculateIndices();

            int i          = 0;
            var duplicates = fmdl.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c);

            foreach (var shape in duplicates)
            {
                shape.Text += i++;
            }

            foreach (FSHP shape in fmdl.shapes)
            {
                BFRES.CheckMissingTextures(shape);
                SetShape(shape, shape.Shape);

                model.Shapes.Add(shape.Shape);
                model.VertexBuffers.Add(shape.VertexBuffer);
                shape.Shape.VertexBufferIndex = (ushort)(model.VertexBuffers.Count - 1);

                //  BFRES.SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape);
            }
            foreach (FMAT mat in fmdl.materials.Values)
            {
                SetMaterial(mat, mat.Material);
                model.Materials.Add(mat.Material);
            }
            return(model);
        }
コード例 #3
0
ファイル: AAMP.cs プロジェクト: lanvas2008/Switch-Toolbox
        private static void GenerateGridData(BFRES bfres, aampv1.ParamEntry[] paramEntries)
        {
            var boundings = bfres.GetBoundingBox();

            foreach (var entry in paramEntries)
            {
                if (entry.HashString == "aabb_min_pos")
                {
                    entry.Value = new Syroot.Maths.Vector3F(boundings.Min.X, boundings.Min.Y, boundings.Min.Z);
                }
                if (entry.HashString == "aabb_max_pos")
                {
                    entry.Value = new Syroot.Maths.Vector3F(boundings.Max.X, boundings.Max.Y, boundings.Max.Z);
                }
            }
        }
コード例 #4
0
        public static Model SetModel(FMDL fmdl)
        {
            Model model = new Model();

            model.Name = fmdl.Text;
            model.Path = "";

            model.Shapes        = new ResDict <Shape>();
            model.VertexBuffers = new List <VertexBuffer>();
            model.Materials     = new ResDict <Material>();
            model.UserData      = new ResDict <UserData>();
            model.Skeleton      = new Skeleton();
            model.Skeleton      = fmdl.Skeleton.node.SkeletonU;
            model.UserData      = fmdl.ModelU.UserData;

            fmdl.Skeleton.CalculateIndices();

            int i          = 0;
            var duplicates = fmdl.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c);

            foreach (var shape in duplicates)
            {
                shape.Text += i++;
            }

            foreach (FSHP shape in fmdl.shapes)
            {
                BFRES.CheckMissingTextures(shape);
                SetShape(shape, shape.ShapeU);

                model.Shapes.Add(shape.Text, shape.ShapeU);
                model.VertexBuffers.Add(shape.VertexBufferU);
                shape.ShapeU.VertexBufferIndex = (ushort)(model.VertexBuffers.Count - 1);

                //   BFRES.SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape);
            }

            foreach (FMAT mat in fmdl.materials.Values)
            {
                SetMaterial(mat, mat.MaterialU, fmdl.GetResFileU());
                model.Materials.Add(mat.Text, mat.MaterialU);
            }
            return(model);
        }
コード例 #5
0
        public static void LoadStage(string MapName)
        {
            string StageByml = $"{Runtime.SmoGamePath}\\StageData\\{MapName}Map.szs";

            Console.WriteLine($"{StageByml} {File.Exists($"{StageByml}")}");
            if (File.Exists($"{StageByml}"))
            {
                var TextureSzs = $"{Runtime.SmoGamePath}\\ObjectData\\{MapName}Texture.szs";

                ObjectEditor editor = new ObjectEditor();
                LibraryGUI.CreateMdiWindow(editor);

                var level = new Level(StageByml, -1);
                foreach (var obj in level.objs)
                {
                    foreach (var ob in obj.Value)
                    {
                        var Transform = Utils.TransformValues(ob.transform.Pos, ob.transform.Rot, ob.transform.Scale);

                        var bfresData = BfresFromSzs(ob.Name);

                        if (bfresData != null)
                        {
                            BFRES bfresFile = (BFRES)STFileLoader.OpenFileFormat(ob.Name, bfresData);
                            bfresFile.BFRESRender.ModelTransform = Transform;

                            editor.AddNode(bfresFile);
                            bfresFile.LoadEditors(null);
                            DiableLoadCheck();
                        }
                    }
                }

                TextureSzs = null;
                GC.Collect();
            }

            BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));

            bfresEditor.DisplayAll = true;
        }
コード例 #6
0
            public void LoadCostume(string fileName)
            {
                List <BFRES> bfresFiles = new List <BFRES>();

                var FileFormat = STFileLoader.OpenFileFormat(fileName);

                if (FileFormat is SARC)
                {
                    foreach (var file in ((SARC)FileFormat).Files)
                    {
                        string ext = System.IO.Path.GetExtension(file.FileName);
                        if (ext == ".bfres")
                        {
                            bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(new System.IO.MemoryStream(file.FileData), file.FileName));
                        }
                    }
                }
                if (FileFormat is BFRES)
                {
                    bfresFiles.Add((BFRES)FileFormat);
                }

                if (editor == null)
                {
                    editor = new ObjectEditor();
                    LibraryGUI.CreateMdiWindow(editor);
                }

                if (MainCostume == null && bfresFiles.Count > 0)
                {
                    MainCostume = bfresFiles[0];
                }

                foreach (var bfres in bfresFiles)
                {
                    editor.AddNode(bfres);
                    bfres.LoadEditors(null);
                    DiableLoadCheck();
                }
            }
コード例 #7
0
        public static Model SetModel(FMDL fmdl)
        {
            Model model = new Model();

            model.Name = fmdl.Text;
            model.Path = "";

            model.Shapes        = new ResDict <Shape>();
            model.VertexBuffers = new List <VertexBuffer>();
            model.Materials     = new ResDict <Material>();
            model.UserData      = new ResDict <UserData>();
            model.Skeleton      = new Skeleton();
            model.Skeleton      = fmdl.Skeleton.node.SkeletonU;
            model.UserData      = fmdl.ModelU.UserData;

            if (model.Skeleton.InverseModelMatrices == null)
            {
                model.Skeleton.InverseModelMatrices = new List <Syroot.Maths.Matrix3x4>();
            }
            if (model.Skeleton.MatrixToBoneList == null)
            {
                model.Skeleton.MatrixToBoneList = new List <ushort>();
            }

            foreach (var bone in fmdl.Skeleton.bones)
            {
                if (model.Skeleton.InverseModelMatrices.Count <= 0)
                {
                    break;
                }

                int inde = 0;
                foreach (var bn in model.Skeleton.Bones.Values)
                {
                    if (bone.Text == bn.Name)
                    {
                        var mat = MatrixExenstion.GetMatrixInverted(bone);

                        if (bn.SmoothMatrixIndex > -1)
                        {
                            model.Skeleton.InverseModelMatrices[bn.SmoothMatrixIndex] = mat;
                        }
                    }
                    inde++;
                }
            }

            int i          = 0;
            var duplicates = fmdl.shapes.GroupBy(c => c.Text).Where(g => g.Skip(1).Any()).SelectMany(c => c);

            foreach (var shape in duplicates)
            {
                shape.Text += i++;
            }

            foreach (FSHP shape in fmdl.shapes)
            {
                BFRES.CheckMissingTextures(shape);
                SetShape(shape, shape.ShapeU);

                model.Shapes.Add(shape.Text, shape.ShapeU);
                model.VertexBuffers.Add(shape.VertexBufferU);
                shape.ShapeU.VertexBufferIndex = (ushort)(model.VertexBuffers.Count - 1);

                //   BFRES.SetShaderAssignAttributes(shape.GetMaterial().shaderassign, shape);
            }

            foreach (FMAT mat in fmdl.materials.Values)
            {
                SetMaterial(mat, mat.MaterialU, fmdl.GetResFileU());
                model.Materials.Add(mat.Text, mat.MaterialU);
            }
            return(model);
        }
コード例 #8
0
ファイル: BFRES_Render.cs プロジェクト: week9/Switch-Toolbox
        public static bool BindTexture(MatTexture tex, FMAT material, SF.Shader shader, bool IsWiiU)
        {
            BFRES bfres = (BFRES)material.Parent.Parent.Parent.Parent;

            GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
            GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);

            string activeTex = tex.Name;

            if (tex.animatedTexName != "")
            {
                activeTex = tex.animatedTexName;
            }

            if (IsWiiU)
            {
                if (bfres.HasTextures)
                {
                    var ftexCont = bfres.GetFTEXContainer;
                    if (ftexCont != null)
                    {
                        if (ftexCont.ResourceNodes.ContainsKey(activeTex))
                        {
                            return(BindFTEX(ftexCont, tex, shader, activeTex));
                        }
                    }
                }

                foreach (var ftexContainer in PluginRuntime.ftexContainers)
                {
                    if (ftexContainer.ResourceNodes.ContainsKey(activeTex))
                    {
                        return(BindFTEX(ftexContainer, tex, shader, activeTex));
                    }
                }
            }
            else
            {
                if (bfres.HasTextures)
                {
                    var bntx = bfres.GetBNTX;
                    if (bntx != null)
                    {
                        if (bntx.Textures.ContainsKey(activeTex))
                        {
                            return(BindBNTX(bntx, tex, shader, activeTex));
                        }
                    }
                }

                foreach (var bntx in PluginRuntime.bntxContainers)
                {
                    if (bntx.Textures.ContainsKey(activeTex))
                    {
                        return(BindBNTX(bntx, tex, shader, activeTex));
                    }
                }
            }

            return(true);
        }