diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 8323a91e..9f428b7e 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index 83a4c851..cc457026 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index ed9991be..c878e24d 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs index 87b6ebeb..12e764a0 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs @@ -12,11 +12,16 @@ using ResUGX2 = Syroot.NintenTools.Bfres.GX2; using ResGFX = Syroot.NintenTools.NSW.Bfres.GFX; using FirstPlugin; using FirstPlugin.Forms; +using OpenTK; namespace Bfres.Structs { public class FMDL : STGenericModel { + //These get updated on UpdateVertexData() + public Vector3 MaxPosition = new Vector3(0); + public Vector3 MinPosition = new Vector3(0); + public bool IsEdited { get; set; } public List shapes = new List(); diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs index 3505af12..bedfab00 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs @@ -1381,7 +1381,7 @@ namespace Bfres.Structs } } - public List CreateDisplayVertices() + public List CreateDisplayVertices(FMDL model) { // rearrange faces display = lodMeshes[DisplayLODIndex].getDisplayFace().ToArray(); @@ -1393,6 +1393,9 @@ namespace Bfres.Structs foreach (Vertex v in vertices) { + model.MaxPosition = OpenGLUtils.GetMax(model.MaxPosition, v.pos); + model.MinPosition = OpenGLUtils.GetMin(model.MinPosition, v.pos); + DisplayVertex displayVert = new DisplayVertex() { pos = v.pos, diff --git a/Switch_FileFormatsMain/GL/BFRES_Render.cs b/Switch_FileFormatsMain/GL/BFRES_Render.cs index 0330c786..41da493a 100644 --- a/Switch_FileFormatsMain/GL/BFRES_Render.cs +++ b/Switch_FileFormatsMain/GL/BFRES_Render.cs @@ -235,6 +235,11 @@ namespace FirstPlugin //Depth sort meshes DepthSortMeshes(control.CameraTarget); } + + public void CenterCamera(GL_ControlModern control) + { + } + public static Vector4 GenerateBoundingSphere(IEnumerable boundingSpheres) { // The initial max/min should be the first point. @@ -286,6 +291,9 @@ namespace FirstPlugin if (models.Count > 0) { + if (models[0].Parent.Parent.IsSelected) + CenterCamera(control); + if (models[0].shapes.Count > 0) { if (models[0].shapes[0].GetMaterial().shaderassign.ShaderModel == "uking_mat") @@ -714,6 +722,10 @@ namespace FirstPlugin foreach (FMDL mdl in models) { + //Reset min/max + mdl.MaxPosition = new Vector3(0); + mdl.MinPosition = new Vector3(0); + foreach (FSHP m in mdl.shapes) { progressBar.Task = "Updating Shape... " + m.Text; @@ -722,7 +734,7 @@ namespace FirstPlugin progressBar.Refresh(); m.Offset = poffset * 4; - List pv = m.CreateDisplayVertices(); + List pv = m.CreateDisplayVertices(mdl); Vs.AddRange(pv); for (int i = 0; i < m.lodMeshes[m.DisplayLODIndex].displayFaceSize; i++) diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache index 067c7176..987fe651 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csproj.GenerateResource.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 30867ac8..b73ab551 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj index 2e05137d..77034687 100644 --- a/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Switch_Toolbox_Library.csproj @@ -642,6 +642,7 @@ + diff --git a/Switch_Toolbox_Library/Util/OpenGLUtils.cs b/Switch_Toolbox_Library/Util/OpenGLUtils.cs new file mode 100644 index 00000000..2f6ed9d3 --- /dev/null +++ b/Switch_Toolbox_Library/Util/OpenGLUtils.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OpenTK; + +namespace Switch_Toolbox.Library +{ + public class OpenGLUtils + { + public static Vector3 GetMax(Vector3 value1, Vector3 value2) + { + Vector3 val = new Vector3(0); + val.X = Math.Max(value1.X, value2.X); + val.Y = Math.Max(value1.Y, value2.Y); + val.Z = Math.Max(value1.Z, value2.Z); + return val; + } + + public static Vector3 GetMin(Vector3 value1, Vector3 value2) + { + Vector3 val = new Vector3(0); + val.X = Math.Min(value1.X, value2.X); + val.Y = Math.Min(value1.Y, value2.Y); + val.Z = Math.Min(value1.Z, value2.Z); + return val; + } + } +}