diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index a43639dc..056c872d 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 daf441c2..9be75533 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 3712c7ab..c1a1cc32 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/FSHP.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs index 494d10f8..816420b6 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs @@ -1090,10 +1090,8 @@ namespace Bfres.Structs if (VertexSkinCount == 1 && vtx.boneIds.Count > 0) boneId = vtx.boneIds[0]; - Console.WriteLine("Old " + vtx.pos); - vtx.pos = TransformLocal(vtx.pos, boneId, VertexSkinCount == 1); - vtx.nrm = TransformLocal(vtx.nrm, boneId, VertexSkinCount == 1, false); - Console.WriteLine("New " + vtx.pos); + // vtx.pos = TransformLocal(vtx.pos, boneId, VertexSkinCount == 1); + // vtx.nrm = TransformLocal(vtx.nrm, boneId, VertexSkinCount == 1, false); } //Console.WriteLine($"Weight count {vtx.boneWeights.Count}"); //Console.WriteLine($"Index count {vtx.boneIds.Count}"); diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs index 7e359d97..1cb4bcc7 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/BfresWiiU.cs @@ -296,9 +296,21 @@ namespace FirstPlugin } if (fshp.VertexSkinCount == 0) { - Matrix4 NoBindFix = model.Skeleton.bones[fshp.BoneIndex].Transform; - v.pos = Vector3.TransformPosition(v.pos, NoBindFix); - v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix); + try + { + if (model.Skeleton.bones.Count > 0) { + Matrix4 NoBindFix = model.Skeleton.bones[fshp.BoneIndex].Transform; + v.pos = Vector3.TransformPosition(v.pos, NoBindFix); + v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix); + } + } + catch //Matrix failed. Print the coordinate data of the bone + { + Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].Text); + Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetPosition()); + Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetRotation()); + Console.WriteLine(model.Skeleton.bones[fshp.BoneIndex].GetScale()); + } } fshp.vertices.Add(v); } diff --git a/Switch_FileFormatsMain/FileFormats/Collision/KCL.cs b/Switch_FileFormatsMain/FileFormats/Collision/KCL.cs index 7de93112..14659fa4 100644 --- a/Switch_FileFormatsMain/FileFormats/Collision/KCL.cs +++ b/Switch_FileFormatsMain/FileFormats/Collision/KCL.cs @@ -263,24 +263,38 @@ namespace FirstPlugin } } + Viewport viewport + { + get + { + var editor = LibraryGUI.Instance.GetObjectEditor(); + return editor.GetViewport(); + } + set + { + var editor = LibraryGUI.Instance.GetObjectEditor(); + editor.LoadViewport(value); + } + } + public KCLRendering Renderer; bool IsLoaded = false; public override void OnClick(TreeView treeView) { - Viewport editor = (Viewport)LibraryGUI.Instance.GetActiveContent(typeof(Viewport)); - - if (editor == null) + if (viewport == null) { - editor = new Viewport(); - LibraryGUI.Instance.LoadEditor(editor); + viewport.Dock = DockStyle.Fill; + viewport.AddDrawable(Renderer); + viewport.LoadObjects(); + LibraryGUI.Instance.LoadEditor(viewport); } - editor.Text = Text; - editor.Dock = DockStyle.Fill; + + viewport.Text = Text; if (!IsLoaded) { - editor.AddDrawable(Renderer); - editor.LoadObjects(); + viewport.AddDrawable(Renderer); + viewport.LoadObjects(); } IsLoaded = true; diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 9a7ccc1f..f91f108c 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll index 1d9e5c3d..d402ffa8 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll differ diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb index 2b5de52c..8c11b7b5 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 01ccbf5c..d6d2b7a5 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/FileFormats/Assimp/Assimp.cs b/Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs index c17cb6fa..392e300b 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs @@ -146,7 +146,6 @@ namespace Switch_Toolbox.Library for (int i = 0; i < _meshChannels.Length; i++) { _meshChannels[i] = new MeshAnimationChannel(); - } } @@ -454,7 +453,6 @@ namespace Switch_Toolbox.Library { foreach (VertexWeight w in bn.VertexWeights) { - // vertices[w.VertexID].pos = Vector3.TransformPosition(vertices[w.VertexID].pos, AssimpHelper.TKMatrix(bn.OffsetMatrix)); vertices[w.VertexID].boneWeights.Add(w.Weight); vertices[w.VertexID].boneNames.Add(bn.Name); BoneNames.Add(bn.Name); diff --git a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs index 8c3f64bf..4de3cf6e 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs @@ -158,9 +158,14 @@ namespace Switch_Toolbox.Library foreach (var tex in genericMat.TextureMaps) { - TextureSlot slot = new TextureSlot(); + int index = Textures.FindIndex(r => r.Text.Equals(tex.Name)); + string path = System.IO.Path.Combine(TexturePath, tex.Name + TextureExtension); + if (!File.Exists(path)) + throw new Exception("Texture not found to map"); + + TextureSlot slot = new TextureSlot(); slot.FilePath = path; slot.UVIndex = 0; slot.Flags = 0; @@ -192,22 +197,22 @@ namespace Switch_Toolbox.Library if (tex.wrapModeS == 0) slot.WrapModeU = TextureWrapMode.Wrap; - if (tex.wrapModeS == 1) + else if (tex.wrapModeS == 1) slot.WrapModeU = TextureWrapMode.Mirror; - if (tex.wrapModeS == 2) + else if (tex.wrapModeS == 2) slot.WrapModeU = TextureWrapMode.Clamp; + else + slot.WrapModeU = TextureWrapMode.Wrap; + if (tex.wrapModeT == 0) slot.WrapModeV = TextureWrapMode.Wrap; - if (tex.wrapModeT == 1) + else if (tex.wrapModeT == 1) slot.WrapModeV = TextureWrapMode.Mirror; - if (tex.wrapModeT == 2) + else if (tex.wrapModeT == 2) slot.WrapModeV = TextureWrapMode.Clamp; else - { - slot.WrapModeU = TextureWrapMode.Wrap; slot.WrapModeV = TextureWrapMode.Wrap; - } - + material.AddMaterialTexture(ref slot); } scene.Materials.Add(material); diff --git a/Toolbox/Lib/SARCExt.dll b/Toolbox/Lib/SARCExt.dll index 7988c580..145d93c6 100644 Binary files a/Toolbox/Lib/SARCExt.dll and b/Toolbox/Lib/SARCExt.dll differ diff --git a/Toolbox/Lib/SARCExt.pdb b/Toolbox/Lib/SARCExt.pdb index 6fa71e31..638eb5e4 100644 Binary files a/Toolbox/Lib/SARCExt.pdb and b/Toolbox/Lib/SARCExt.pdb differ