diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index 6a03629a..e09d7233 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 22fc8a72..eabb1064 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-shm b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm index d7c6ae12..7b42c37b 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index 64501477..aa273079 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/GL/BFRES_Render.cs b/Switch_FileFormatsMain/GL/BFRES_Render.cs index 22b4fb52..83310e5a 100644 --- a/Switch_FileFormatsMain/GL/BFRES_Render.cs +++ b/Switch_FileFormatsMain/GL/BFRES_Render.cs @@ -199,6 +199,40 @@ namespace FirstPlugin if (!Runtime.OpenTKInitialized) return; + Matrix4 mvpMat = control.ModelMatrix * control.CameraMatrix * control.ProjectionMatrix; + + Matrix4 invertedCamera = Matrix4.Identity; + if (invertedCamera.Determinant != 0) + invertedCamera = mvpMat.Inverted(); + + Vector3 lightDirection = new Vector3(0f, 0f, -1f); + Vector3 difLightDirection = Vector3.TransformNormal(lightDirection, invertedCamera).Normalized(); + + GL.Disable(EnableCap.Texture2D); + GL.Enable(EnableCap.DepthTest); + + foreach (var model in models) + { + foreach (var shape in model.shapes) + { + if (Runtime.RenderModels && model.Checked && shape.Checked) + { + List faces = shape.lodMeshes[shape.DisplayLODIndex].getDisplayFace(); + + GL.Begin(PrimitiveType.Triangles); + foreach (var index in faces) + { + Vertex vert = shape.vertices[index]; + float normal = Vector3.Dot(difLightDirection, vert.nrm) * 0.5f + 0.5f; + GL.Color3(new Vector3(normal)); + GL.Vertex3(vert.pos); + } + GL.End(); + } + } + } + + GL.Enable(EnableCap.Texture2D); } public void CenterCamera(GL_ControlModern control) @@ -540,6 +574,8 @@ namespace FirstPlugin public static int BindTexture(SF.Shader shader, MatTexture tex, FMAT material, bool IsWiiU) { BFRES bfres = (BFRES)material.Parent.Parent.Parent.Parent; + if (material.Parent == null || bfres == null) //Bfres disposed + return -1; GL.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1); GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID); diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index f3711ece..055e6799 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/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 48f85534..d61ca82c 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/AssimpSaver.cs b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs index 218c33f3..6ed5f73f 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/AssimpSaver.cs @@ -144,15 +144,17 @@ namespace Switch_Toolbox.Library boneInd = mesh.Bones.IndexOf(bone); //Set the index of the bone for the vertex weight } + int MinWeightAmount = 0; + //Check if the max amount of weights is higher than the current bone id - if (v.boneWeights.Count > j && v.boneWeights[j] > 0) + if (v.boneWeights.Count > j && v.boneWeights[j] > MinWeightAmount) { if (v.boneWeights[j] <= 1) mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, v.boneWeights[j])); else mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, 1)); } - else if (v.boneWeights.Count == 0 || v.boneWeights[j] > 0) + else if (v.boneWeights.Count == 0 || v.boneWeights[j] > MinWeightAmount) mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, 1)); } } diff --git a/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs b/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs index 7cd3720b..24eed0d3 100644 --- a/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs +++ b/Switch_Toolbox_Library/Forms/Custom/BarSlider/BarSlider.cs @@ -217,7 +217,8 @@ namespace BarSlider if (TextEditorActive) return; - Cursor.Position = prevPos; + if (prevPos.X != 0 && prevPos.Y != 0) + Cursor.Position = prevPos; Cursor.Show(); } diff --git a/Switch_Toolbox_Library/Generics/STSkeleton.cs b/Switch_Toolbox_Library/Generics/STSkeleton.cs index 2c13a5ef..9bfca4bf 100644 --- a/Switch_Toolbox_Library/Generics/STSkeleton.cs +++ b/Switch_Toolbox_Library/Generics/STSkeleton.cs @@ -53,10 +53,16 @@ namespace Switch_Toolbox.Library if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT) return; + if (Runtime.boneXrayDisplay) + GL.Disable(EnableCap.DepthTest); + + GL.Disable(EnableCap.Texture2D); foreach (STBone bn in bones) { bn.RenderLegacy(); } + GL.Enable(EnableCap.Texture2D); + GL.Enable(EnableCap.DepthTest); } public override void Draw(GL_ControlLegacy control, Pass pass) @@ -64,10 +70,16 @@ namespace Switch_Toolbox.Library if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT) return; + if (Runtime.boneXrayDisplay) + GL.Disable(EnableCap.DepthTest); + + GL.Disable(EnableCap.Texture2D); foreach (STBone bn in bones) { bn.RenderLegacy(); } + GL.Enable(EnableCap.Texture2D); + GL.Enable(EnableCap.DepthTest); } private static List screenPositions = new List() diff --git a/Switch_Toolbox_Library/Rendering/DrawableBackground.cs b/Switch_Toolbox_Library/Rendering/DrawableBackground.cs index 1d021553..4d0c4de2 100644 --- a/Switch_Toolbox_Library/Rendering/DrawableBackground.cs +++ b/Switch_Toolbox_Library/Rendering/DrawableBackground.cs @@ -91,14 +91,13 @@ namespace Switch_Toolbox.Library.Rendering return; GL.MatrixMode(MatrixMode.Projection); + GL.PushMatrix(); GL.LoadIdentity(); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); GL.Disable(EnableCap.Texture2D); - GL.MatrixMode(MatrixMode.Modelview); - GL.LoadIdentity(); GL.Begin(PrimitiveType.TriangleStrip); GL.Color3(Runtime.backgroundGradientTop); GL.Vertex3(1, 1, 0.99998); @@ -111,6 +110,8 @@ namespace Switch_Toolbox.Library.Rendering GL.UseProgram(0); GL.Enable(EnableCap.CullFace); + + GL.PopMatrix(); } public override void Prepare(GL_ControlModern control) diff --git a/Switch_Toolbox_Library/Rendering/DrawableFloor.cs b/Switch_Toolbox_Library/Rendering/DrawableFloor.cs index 0b0ccb60..a4e2eb50 100644 --- a/Switch_Toolbox_Library/Rendering/DrawableFloor.cs +++ b/Switch_Toolbox_Library/Rendering/DrawableFloor.cs @@ -127,7 +127,8 @@ namespace Switch_Toolbox.Library.Rendering var color = Runtime.gridSettings.color; GL.UseProgram(0); - // GL.MatrixMode(MatrixMode.Modelview); + GL.Disable(EnableCap.Texture2D); + // GL.MatrixMode(MatrixMode.Modelview); GL.PushAttrib(AttribMask.AllAttribBits); var trans = Matrix4.Identity; @@ -146,6 +147,7 @@ namespace Switch_Toolbox.Library.Rendering GL.End(); GL.Color3(Color.Transparent); GL.PopAttrib(); + GL.Enable(EnableCap.Texture2D); } public override void Prepare(GL_ControlModern control) diff --git a/Switch_Toolbox_Library/Rendering/DrawableXyzLines.cs b/Switch_Toolbox_Library/Rendering/DrawableXyzLines.cs index c437a997..50f9e00d 100644 --- a/Switch_Toolbox_Library/Rendering/DrawableXyzLines.cs +++ b/Switch_Toolbox_Library/Rendering/DrawableXyzLines.cs @@ -98,7 +98,6 @@ namespace Switch_Toolbox.Library.Rendering GL.UseProgram(0); GL.Disable(EnableCap.CullFace); - GL.Disable(EnableCap.DepthTest); control.CurrentShader = solidColorShaderProgram; @@ -143,7 +142,7 @@ namespace Switch_Toolbox.Library.Rendering var color = Runtime.gridSettings.color; GL.UseProgram(0); - // GL.MatrixMode(MatrixMode.Modelview); + GL.Disable(EnableCap.Texture2D); GL.PushAttrib(AttribMask.AllAttribBits); var trans = Matrix4.Identity; @@ -162,6 +161,7 @@ namespace Switch_Toolbox.Library.Rendering GL.End(); GL.Color3(Color.Transparent); GL.PopAttrib(); + GL.Enable(EnableCap.Texture2D); } public override void Prepare(GL_ControlModern control) diff --git a/Toolbox/Lib/x64/DirectXTexNetImpl.dll b/Toolbox/Lib/x64/DirectXTexNetImpl.dll deleted file mode 100644 index 27f3041d..00000000 Binary files a/Toolbox/Lib/x64/DirectXTexNetImpl.dll and /dev/null differ diff --git a/Toolbox/Toolbox.csproj b/Toolbox/Toolbox.csproj index 0e4173e6..a82ea251 100644 --- a/Toolbox/Toolbox.csproj +++ b/Toolbox/Toolbox.csproj @@ -466,9 +466,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest