From f345e5ec59b14980e92b830e0574eee58e56fd12 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Wed, 1 Apr 2020 15:23:55 -0400 Subject: [PATCH] BFRES : Add option to create dummy LODs that point to first level. --- .../BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs | 33 +++++++++++++++++++ .../FileFormats/BFRES/BfresSwitch.cs | 5 --- .../FileFormats/BFRES/BfresWiiU.cs | 3 -- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs index 96246a69..0771630a 100644 --- a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs +++ b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs @@ -174,6 +174,7 @@ namespace Bfres.Structs ToolStripMenuItem lodMenu = new ToolStripMenuItem("Level Of Detail"); lodMenu.DropDownItems.Add(new ToolStripMenuItem("Clear LOD Meshes", null, ClearLODMeshes)); + lodMenu.DropDownItems.Add(new ToolStripMenuItem("Add dummy LOD Meshes", null, GenerateDummyLODMeshesAction)); Items.Add(lodMenu); ToolStripMenuItem boundingsMenu = new ToolStripMenuItem("Boundings"); @@ -355,6 +356,38 @@ namespace Bfres.Structs Cursor.Current = Cursors.Default; } + private void GenerateDummyLODMeshesAction(object sender, EventArgs args) + { + Cursor.Current = Cursors.WaitCursor; + GenerateDummyLODMeshes(); + Cursor.Current = Cursors.Default; + } + + public void GenerateDummyLODMeshes() + { + var mesh = lodMeshes.FirstOrDefault(); + while (true) + { + if (lodMeshes.Count >= 3) + break; + + LOD_Mesh lod = new LOD_Mesh(); + lod.faces.AddRange(mesh.faces); + lod.IndexFormat = mesh.IndexFormat; + lodMeshes.Add(lod); + + var subMesh = new LOD_Mesh.SubMesh(); + subMesh.offset = mesh.subMeshes[0].offset; + subMesh.size = mesh.subMeshes[0].size; + lod.subMeshes.Add(subMesh); + } + + CreateNewBoundingBoxes(); + SaveShape(GetResFileU() != null); + UpdateVertexData(); + GenerateBoundingNodes(); + } + private void GenerateLODMeshes(object sender, EventArgs args) { Cursor.Current = Cursors.WaitCursor; diff --git a/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs b/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs index 742f8f6b..f9b0a615 100644 --- a/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs +++ b/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs @@ -167,16 +167,11 @@ namespace FirstPlugin faceList.Add((uint)f); } if (faceList.Count > 65000) - { - MessageBox.Show($"Warning! Your poly count for a single mesh {fshp.Text} is pretty high! ({faceList.Count})." + - $" You may want to split this!"); msh.SetIndices(faceList, IndexFormat.UInt32); - } else msh.SetIndices(faceList, IndexFormat.UInt16); Shape.Meshes.Add(msh); - break; } return Shape; } diff --git a/File_Format_Library/FileFormats/BFRES/BfresWiiU.cs b/File_Format_Library/FileFormats/BFRES/BfresWiiU.cs index a675af6d..caee7d08 100644 --- a/File_Format_Library/FileFormats/BFRES/BfresWiiU.cs +++ b/File_Format_Library/FileFormats/BFRES/BfresWiiU.cs @@ -936,15 +936,12 @@ namespace FirstPlugin } if (faceList.Count > 65000) { - MessageBox.Show($"Warning! Your poly count for a single mesh {fshp.Text} is pretty high! ({faceList.Count})." + - $" You may want to split this!"); msh.SetIndices(faceList, GX2IndexFormat.UInt32); } else msh.SetIndices(faceList, GX2IndexFormat.UInt16); ShapeU.Meshes.Add(msh); - break; } return ShapeU; }