Improve legacy support and a few fixes.

Cursor for param editing doesn't reset anymore to the top right of the screen.
Fixed some direct c tex issues with loading.
This commit is contained in:
KillzXGaming 2019-05-31 15:08:14 -04:00
parent 79ca72bc98
commit 921b267b44
15 changed files with 62 additions and 11 deletions

Binary file not shown.

View file

@ -199,6 +199,40 @@ namespace FirstPlugin
if (!Runtime.OpenTKInitialized) if (!Runtime.OpenTKInitialized)
return; 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<int> 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) 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) public static int BindTexture(SF.Shader shader, MatTexture tex, FMAT material, bool IsWiiU)
{ {
BFRES bfres = (BFRES)material.Parent.Parent.Parent.Parent; 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.ActiveTexture(TextureUnit.Texture0 + tex.textureUnit + 1);
GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID); GL.BindTexture(TextureTarget.Texture2D, RenderTools.defaultTex.RenderableTex.TexID);

View file

@ -144,15 +144,17 @@ namespace Switch_Toolbox.Library
boneInd = mesh.Bones.IndexOf(bone); //Set the index of the bone for the vertex weight 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 //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) if (v.boneWeights[j] <= 1)
mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, v.boneWeights[j])); mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, v.boneWeights[j]));
else else
mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, 1)); 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)); mesh.Bones[boneInd].VertexWeights.Add(new VertexWeight(vertexID, 1));
} }
} }

View file

@ -217,7 +217,8 @@ namespace BarSlider
if (TextEditorActive) if (TextEditorActive)
return; return;
Cursor.Position = prevPos; if (prevPos.X != 0 && prevPos.Y != 0)
Cursor.Position = prevPos;
Cursor.Show(); Cursor.Show();
} }

View file

@ -53,10 +53,16 @@ namespace Switch_Toolbox.Library
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT) if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT)
return; return;
if (Runtime.boneXrayDisplay)
GL.Disable(EnableCap.DepthTest);
GL.Disable(EnableCap.Texture2D);
foreach (STBone bn in bones) foreach (STBone bn in bones)
{ {
bn.RenderLegacy(); bn.RenderLegacy();
} }
GL.Enable(EnableCap.Texture2D);
GL.Enable(EnableCap.DepthTest);
} }
public override void Draw(GL_ControlLegacy control, Pass pass) public override void Draw(GL_ControlLegacy control, Pass pass)
@ -64,10 +70,16 @@ namespace Switch_Toolbox.Library
if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT) if (!Runtime.OpenTKInitialized || pass == Pass.TRANSPARENT)
return; return;
if (Runtime.boneXrayDisplay)
GL.Disable(EnableCap.DepthTest);
GL.Disable(EnableCap.Texture2D);
foreach (STBone bn in bones) foreach (STBone bn in bones)
{ {
bn.RenderLegacy(); bn.RenderLegacy();
} }
GL.Enable(EnableCap.Texture2D);
GL.Enable(EnableCap.DepthTest);
} }
private static List<Vector4> screenPositions = new List<Vector4>() private static List<Vector4> screenPositions = new List<Vector4>()

View file

@ -91,14 +91,13 @@ namespace Switch_Toolbox.Library.Rendering
return; return;
GL.MatrixMode(MatrixMode.Projection); GL.MatrixMode(MatrixMode.Projection);
GL.PushMatrix();
GL.LoadIdentity(); GL.LoadIdentity();
GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(DepthFunction.Lequal); GL.DepthFunc(DepthFunction.Lequal);
GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.Texture2D);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.Begin(PrimitiveType.TriangleStrip); GL.Begin(PrimitiveType.TriangleStrip);
GL.Color3(Runtime.backgroundGradientTop); GL.Color3(Runtime.backgroundGradientTop);
GL.Vertex3(1, 1, 0.99998); GL.Vertex3(1, 1, 0.99998);
@ -111,6 +110,8 @@ namespace Switch_Toolbox.Library.Rendering
GL.UseProgram(0); GL.UseProgram(0);
GL.Enable(EnableCap.CullFace); GL.Enable(EnableCap.CullFace);
GL.PopMatrix();
} }
public override void Prepare(GL_ControlModern control) public override void Prepare(GL_ControlModern control)

View file

@ -127,7 +127,8 @@ namespace Switch_Toolbox.Library.Rendering
var color = Runtime.gridSettings.color; var color = Runtime.gridSettings.color;
GL.UseProgram(0); GL.UseProgram(0);
// GL.MatrixMode(MatrixMode.Modelview); GL.Disable(EnableCap.Texture2D);
// GL.MatrixMode(MatrixMode.Modelview);
GL.PushAttrib(AttribMask.AllAttribBits); GL.PushAttrib(AttribMask.AllAttribBits);
var trans = Matrix4.Identity; var trans = Matrix4.Identity;
@ -146,6 +147,7 @@ namespace Switch_Toolbox.Library.Rendering
GL.End(); GL.End();
GL.Color3(Color.Transparent); GL.Color3(Color.Transparent);
GL.PopAttrib(); GL.PopAttrib();
GL.Enable(EnableCap.Texture2D);
} }
public override void Prepare(GL_ControlModern control) public override void Prepare(GL_ControlModern control)

View file

@ -98,7 +98,6 @@ namespace Switch_Toolbox.Library.Rendering
GL.UseProgram(0); GL.UseProgram(0);
GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.CullFace);
GL.Disable(EnableCap.DepthTest); GL.Disable(EnableCap.DepthTest);
control.CurrentShader = solidColorShaderProgram; control.CurrentShader = solidColorShaderProgram;
@ -143,7 +142,7 @@ namespace Switch_Toolbox.Library.Rendering
var color = Runtime.gridSettings.color; var color = Runtime.gridSettings.color;
GL.UseProgram(0); GL.UseProgram(0);
// GL.MatrixMode(MatrixMode.Modelview); GL.Disable(EnableCap.Texture2D);
GL.PushAttrib(AttribMask.AllAttribBits); GL.PushAttrib(AttribMask.AllAttribBits);
var trans = Matrix4.Identity; var trans = Matrix4.Identity;
@ -162,6 +161,7 @@ namespace Switch_Toolbox.Library.Rendering
GL.End(); GL.End();
GL.Color3(Color.Transparent); GL.Color3(Color.Transparent);
GL.PopAttrib(); GL.PopAttrib();
GL.Enable(EnableCap.Texture2D);
} }
public override void Prepare(GL_ControlModern control) public override void Prepare(GL_ControlModern control)

View file

@ -466,9 +466,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Projects\Recent\DUMMY.txt" /> <Content Include="Projects\Recent\DUMMY.txt" />
<Content Include="Lib\x64\DirectXTexNetImpl.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Lib\x86\DirectXTexNetImpl.dll"> <Content Include="Lib\x86\DirectXTexNetImpl.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>