From 0190aef233dc5a89f084a94d06bf40b8c27cd331 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Wed, 11 Dec 2019 20:37:21 -0500 Subject: [PATCH] GFBMDL : Fix swapping meshes with multiple nodes using the same key --- .../FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs | 32 ++----------------- Switch_Toolbox_Library/FileFormats/DAE/DAE.cs | 31 ++++++++++++++++++ 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs index 071980cf..2bfdc6a0 100644 --- a/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs +++ b/File_Format_Library/FileFormats/Pokemon/GFLX/GFBMDL/GFBMDL.cs @@ -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); } diff --git a/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs b/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs index 4f2eac52..e62c81d4 100644 --- a/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs +++ b/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs @@ -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 triangleLists = new List(); if (mesh.lodMeshes.Count > 0) {