1
0
mirror of synced 2024-11-12 02:00:50 +01:00

GFBMDL : Fix swapping meshes with multiple nodes using the same key

This commit is contained in:
KillzXGaming 2019-12-11 20:37:21 -05:00
parent 5aca73d1bc
commit 0190aef233
2 changed files with 34 additions and 29 deletions

View File

@ -391,8 +391,9 @@ namespace FirstPlugin
if (Model.GenericMeshes.Any(x => x.Text == node.Text))
{
NodeIndices.Add(node.Text, i);
Console.WriteLine($"match {node.Text}");
if (!NodeIndices.ContainsKey(node.Text))
NodeIndices.Add(node.Text, i);
Model.Model.Bones.Remove(node.Bone);
Model.Skeleton.bones.Remove(node);
}
@ -632,33 +633,6 @@ namespace FirstPlugin
textures.Add(tex);
}
foreach (var mesh in model.Objects)
{
foreach (var poly in mesh.PolygonGroups)
{
GFLXMaterialData mat = (GFLXMaterialData)poly.Material;
var faces = poly.GetDisplayFace();
for (int v = 0; v < poly.displayFaceSize; v += 3)
{
if (faces.Count < v + 2)
break;
var diffuse = mat.TextureMaps.FirstOrDefault(x => x.Type == STGenericMatTexture.TextureType.Diffuse);
STTextureTransform transform = new STTextureTransform();
if (diffuse != null)
transform = diffuse.Transform;
/* mesh.vertices[faces[v]].uv0 *= transform.Scale;
mesh.vertices[faces[v + 1]].uv0 *= transform.Scale;
mesh.vertices[faces[v + 2]].uv0 *= transform.Scale;
mesh.vertices[faces[v]].uv0 += transform.Translate;
mesh.vertices[faces[v + 1]].uv0 += transform.Translate;
mesh.vertices[faces[v + 2]].uv0 += transform.Translate;*/
}
}
}
DAE.Export(fileName, settings, model, textures, Model.Skeleton);
}

View File

@ -26,6 +26,8 @@ namespace Toolbox.Library
public bool FlipTexCoordsVertical = true;
public bool OnlyExportRiggedBones = false;
public bool TransformColorUVs = false;
public bool AddLeafBones = false;
public Version FileVersion = new Version();
@ -386,6 +388,35 @@ namespace Toolbox.Library
BoneWeights.Add(bWeights.ToArray());
}
if (settings.TransformColorUVs)
{
foreach (var poly in mesh.PolygonGroups)
{
var mat = poly.Material;
if (mat == null) continue;
var faces = poly.GetDisplayFace();
for (int v = 0; v < poly.displayFaceSize; v += 3)
{
if (faces.Count < v + 2)
break;
var diffuse = mat.TextureMaps.FirstOrDefault(x => x.Type == STGenericMatTexture.TextureType.Diffuse);
STTextureTransform transform = new STTextureTransform();
if (diffuse != null)
transform = diffuse.Transform;
mesh.vertices[faces[v]].uv0 *= transform.Scale;
mesh.vertices[faces[v + 1]].uv0 *= transform.Scale;
mesh.vertices[faces[v + 2]].uv0 *= transform.Scale;
mesh.vertices[faces[v]].uv0 += transform.Translate;
mesh.vertices[faces[v + 1]].uv0 += transform.Translate;
mesh.vertices[faces[v + 2]].uv0 += transform.Translate;
}
}
}
List<TriangleList> triangleLists = new List<TriangleList>();
if (mesh.lodMeshes.Count > 0)
{