1
0
mirror of synced 2024-09-24 03:28:21 +02:00

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)
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)
@ -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);

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
}
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));
}
}

View File

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

View File

@ -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<Vector4> screenPositions = new List<Vector4>()

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

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