diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 98f4042b..ed494564 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 cd8420ec..0d897321 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 fe6279a1..1eb2e636 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 816420b6..f5d07427 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL/FSHP.cs @@ -909,19 +909,22 @@ namespace Bfres.Structs { var skel = GetParentModel().Skeleton; Matrix4 trans = Matrix4.Identity; - if (IsSingleBind) { if (BoneIndex >= skel.Node_Array.Length || BoneIndex == -1) return position; var bone = skel.bones[skel.Node_Array[BoneIndex]]; - trans = bone.invert; + + if (trans.Determinant != 0) + trans = bone.invert; } else { var bone = skel.bones[BoneIndex]; - trans = bone.invert; + + if (trans.Determinant != 0) + trans = bone.invert; } if (IsPos) @@ -1090,8 +1093,8 @@ namespace Bfres.Structs if (VertexSkinCount == 1 && vtx.boneIds.Count > 0) boneId = vtx.boneIds[0]; - // vtx.pos = TransformLocal(vtx.pos, boneId, VertexSkinCount == 1); - // vtx.nrm = TransformLocal(vtx.nrm, boneId, VertexSkinCount == 1, false); + 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/GL/BFRES_Render.cs b/Switch_FileFormatsMain/GL/BFRES_Render.cs index 0a7d09a8..277ced5f 100644 --- a/Switch_FileFormatsMain/GL/BFRES_Render.cs +++ b/Switch_FileFormatsMain/GL/BFRES_Render.cs @@ -296,7 +296,10 @@ namespace FirstPlugin Matrix4 camMat = previewScale * control.mtxCam * control.mtxProj; Matrix4 sphereMatrix = camMat; - sphereMatrix.Invert(); + + if (sphereMatrix.Determinant != 0) + sphereMatrix.Invert(); + sphereMatrix.Transpose(); shader.SetMatrix4x4("sphereMatrix", ref sphereMatrix); @@ -308,7 +311,10 @@ namespace FirstPlugin shader.SetVector3("difLightColor", new Vector3(1)); shader.SetVector3("ambLightColor", new Vector3(1)); - Matrix4 invertedCamera = camMat.Inverted(); + Matrix4 invertedCamera = Matrix4.Identity; + if (invertedCamera.Determinant != 0) + invertedCamera = camMat.Inverted(); + Vector3 lightDirection = new Vector3(0f, 0f, -1f); //Todo. Maybe change direction via AAMP file (configs shader data) @@ -427,10 +433,6 @@ namespace FirstPlugin { for (int i = 0; i < fmdl.Skeleton.Node_Array.Length; i++) { - // if (!fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].Visible) - // fshp.Checked = false; - - GL.Uniform1(GL.GetUniformLocation(shader.program, String.Format("boneIds[{0}]", i)), fmdl.Skeleton.Node_Array[i]); Matrix4 transform = fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].invert * fmdl.Skeleton.bones[fmdl.Skeleton.Node_Array[i]].Transform; diff --git a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.dll index c208aa85..2ea752b8 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 c2c24073..6a233a7a 100644 Binary files a/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb and b/Switch_FileFormatsMain/obj/Release/FirstPlugin.Plg.pdb differ