GFBMDL : Fix swapping meshes with multiple nodes using the same key
This commit is contained in:
parent
5aca73d1bc
commit
0190aef233
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user