mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 06:20:24 +00:00
Some fixes with gfbmdl faces
This commit is contained in:
parent
94bcbd5822
commit
8097845a1b
3 changed files with 49 additions and 18 deletions
|
@ -40,7 +40,9 @@ namespace FirstPlugin
|
||||||
{
|
{
|
||||||
List<ToolStripItem> Items = new List<ToolStripItem>();
|
List<ToolStripItem> Items = new List<ToolStripItem>();
|
||||||
var uvMenu = new ToolStripMenuItem("UVs");
|
var uvMenu = new ToolStripMenuItem("UVs");
|
||||||
|
var normalsMenu = new ToolStripMenuItem("Normals");
|
||||||
Items.Add(uvMenu);
|
Items.Add(uvMenu);
|
||||||
|
Items.Add(normalsMenu);
|
||||||
|
|
||||||
Items.Add(new ToolStripMenuItem("Recalculate Bitangents", null, CalculateTangentBitangenAction, Keys.Control | Keys.T));
|
Items.Add(new ToolStripMenuItem("Recalculate Bitangents", null, CalculateTangentBitangenAction, Keys.Control | Keys.T));
|
||||||
uvMenu.DropDownItems.Add(new ToolStripMenuItem("Flip Vertical", null, FlipVerticalAction, Keys.Control | Keys.V));
|
uvMenu.DropDownItems.Add(new ToolStripMenuItem("Flip Vertical", null, FlipVerticalAction, Keys.Control | Keys.V));
|
||||||
|
@ -48,7 +50,10 @@ namespace FirstPlugin
|
||||||
var colorMenu = new ToolStripMenuItem("Vertex Colors");
|
var colorMenu = new ToolStripMenuItem("Vertex Colors");
|
||||||
colorMenu.DropDownItems.Add(new ToolStripMenuItem("Set Color", null, SetVertexColorDialog, Keys.Control | Keys.C));
|
colorMenu.DropDownItems.Add(new ToolStripMenuItem("Set Color", null, SetVertexColorDialog, Keys.Control | Keys.C));
|
||||||
colorMenu.DropDownItems.Add(new ToolStripMenuItem("Convert Normals", null, SetVertexColorNormals, Keys.Control | Keys.N));
|
colorMenu.DropDownItems.Add(new ToolStripMenuItem("Convert Normals", null, SetVertexColorNormals, Keys.Control | Keys.N));
|
||||||
|
normalsMenu.DropDownItems.Add(new ToolStripMenuItem("Recalculate", null, RecalculateNormals, Keys.Control | Keys.R));
|
||||||
|
normalsMenu.DropDownItems.Add(new ToolStripMenuItem("Smooth", null, SmoothNormals, Keys.Control | Keys.S));
|
||||||
|
|
||||||
|
|
||||||
Items.Add(colorMenu);
|
Items.Add(colorMenu);
|
||||||
|
|
||||||
return Items.ToArray();
|
return Items.ToArray();
|
||||||
|
@ -101,6 +106,22 @@ namespace FirstPlugin
|
||||||
UpdateMesh();
|
UpdateMesh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RecalculateNormals(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
CalculateNormals();
|
||||||
|
UpdateMesh();
|
||||||
|
Cursor.Current = Cursors.Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SmoothNormals(object sender, EventArgs args)
|
||||||
|
{
|
||||||
|
Cursor.Current = Cursors.WaitCursor;
|
||||||
|
SmoothNormals();
|
||||||
|
UpdateMesh();
|
||||||
|
Cursor.Current = Cursors.Default;
|
||||||
|
}
|
||||||
|
|
||||||
private void CalculateTangentBitangenAction(object sender, EventArgs args)
|
private void CalculateTangentBitangenAction(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
this.CalculateTangentBitangent(false);
|
this.CalculateTangentBitangent(false);
|
||||||
|
|
|
@ -51,10 +51,14 @@ namespace FirstPlugin
|
||||||
values.Add(mesh.vertices[v].pos.Z);
|
values.Add(mesh.vertices[v].pos.Z);
|
||||||
break;
|
break;
|
||||||
case VertexType.Normal:
|
case VertexType.Normal:
|
||||||
values.Add(mesh.vertices[v].nrm.X);
|
OpenTK.Vector4 normal = new OpenTK.Vector4(mesh.vertices[v].nrm.X,
|
||||||
values.Add(mesh.vertices[v].nrm.Y);
|
mesh.vertices[v].nrm.Y, mesh.vertices[v].nrm.Z,
|
||||||
values.Add(mesh.vertices[v].nrm.Z);
|
mesh.vertices[v].normalW);
|
||||||
values.Add(mesh.vertices[v].normalW);
|
|
||||||
|
values.Add(normal.X);
|
||||||
|
values.Add(normal.Y);
|
||||||
|
values.Add(normal.Z);
|
||||||
|
values.Add(normal.W);
|
||||||
break;
|
break;
|
||||||
case VertexType.Color1:
|
case VertexType.Color1:
|
||||||
values.Add(mesh.vertices[v].col.X * 255);
|
values.Add(mesh.vertices[v].col.X * 255);
|
||||||
|
|
|
@ -279,14 +279,7 @@ namespace Toolbox.Library
|
||||||
if (vertices.Count < 3)
|
if (vertices.Count < 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<int> f = new List<int>();
|
List<int> f = GetFaces();
|
||||||
if (lodMeshes.Count > 0)
|
|
||||||
f = lodMeshes[DisplayLODIndex].getDisplayFace();
|
|
||||||
if (PolygonGroups.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (var group in PolygonGroups)
|
|
||||||
f.AddRange(group.GetDisplayFace());
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector3[] tanArray = new Vector3[vertices.Count];
|
Vector3[] tanArray = new Vector3[vertices.Count];
|
||||||
Vector3[] bitanArray = new Vector3[vertices.Count];
|
Vector3[] bitanArray = new Vector3[vertices.Count];
|
||||||
|
@ -416,9 +409,9 @@ namespace Toolbox.Library
|
||||||
|
|
||||||
Vector3[] normals = new Vector3[Shapes[s].vertices.Count];
|
Vector3[] normals = new Vector3[Shapes[s].vertices.Count];
|
||||||
|
|
||||||
List<int> f = Shapes[s].lodMeshes[DisplayLODIndex].getDisplayFace();
|
List<int> f = Shapes[s].GetFaces();
|
||||||
|
|
||||||
for (int v = 0; v < Shapes[s].lodMeshes[DisplayLODIndex].displayFaceSize; v += 3)
|
for (int v = 0; v < f.Count; v += 3)
|
||||||
{
|
{
|
||||||
Vertex v1 = Shapes[s].vertices[f[v]];
|
Vertex v1 = Shapes[s].vertices[f[v]];
|
||||||
Vertex v2 = Shapes[s].vertices[f[v + 1]];
|
Vertex v2 = Shapes[s].vertices[f[v + 1]];
|
||||||
|
@ -498,9 +491,9 @@ namespace Toolbox.Library
|
||||||
|
|
||||||
Vector3[] normals = new Vector3[vertices.Count];
|
Vector3[] normals = new Vector3[vertices.Count];
|
||||||
|
|
||||||
List<int> f = lodMeshes[DisplayLODIndex].getDisplayFace();
|
List<int> f = GetFaces();
|
||||||
|
|
||||||
for (int i = 0; i < lodMeshes[DisplayLODIndex].displayFaceSize; i += 3)
|
for (int i = 0; i < f.Count; i += 3)
|
||||||
{
|
{
|
||||||
Vertex v1 = vertices[f[i]];
|
Vertex v1 = vertices[f[i]];
|
||||||
Vertex v2 = vertices[f[i + 1]];
|
Vertex v2 = vertices[f[i + 1]];
|
||||||
|
@ -562,9 +555,9 @@ namespace Toolbox.Library
|
||||||
for (int i = 0; i < normals.Length; i++)
|
for (int i = 0; i < normals.Length; i++)
|
||||||
normals[i] = new Vector3(0, 0, 0);
|
normals[i] = new Vector3(0, 0, 0);
|
||||||
|
|
||||||
List<int> f = lodMeshes[DisplayLODIndex].getDisplayFace();
|
List<int> f = GetFaces();
|
||||||
|
|
||||||
for (int i = 0; i < lodMeshes[DisplayLODIndex].displayFaceSize; i += 3)
|
for (int i = 0; i < f.Count; i += 3)
|
||||||
{
|
{
|
||||||
Vertex v1 = vertices[f[i]];
|
Vertex v1 = vertices[f[i]];
|
||||||
Vertex v2 = vertices[f[i + 1]];
|
Vertex v2 = vertices[f[i + 1]];
|
||||||
|
@ -580,6 +573,19 @@ namespace Toolbox.Library
|
||||||
vertices[i].nrm = normals[i].Normalized();
|
vertices[i].nrm = normals[i].Normalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<int> GetFaces()
|
||||||
|
{
|
||||||
|
List<int> f = new List<int>();
|
||||||
|
if (PolygonGroups.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var group in PolygonGroups)
|
||||||
|
f.AddRange(group.GetDisplayFace());
|
||||||
|
}
|
||||||
|
else if (lodMeshes.Count > 0)
|
||||||
|
f = lodMeshes[DisplayLODIndex].getDisplayFace();
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
private Vector3 CalculateNormal(Vertex v1, Vertex v2, Vertex v3)
|
private Vector3 CalculateNormal(Vertex v1, Vertex v2, Vertex v3)
|
||||||
{
|
{
|
||||||
Vector3 U = v2.pos - v1.pos;
|
Vector3 U = v2.pos - v1.pos;
|
||||||
|
|
Loading…
Reference in a new issue