DA4E : Fix a bug with material mapping on export

This commit is contained in:
KillzXGaming 2020-04-01 11:45:08 -04:00
parent 06abad5d4a
commit 9c9c9126a5
3 changed files with 5 additions and 2 deletions

View file

@ -354,6 +354,8 @@ namespace FirstPlugin
var textures = new List<STGenericTexture>(); var textures = new List<STGenericTexture>();
foreach (var mesh in Renderer.Meshes) foreach (var mesh in Renderer.Meshes)
materials.Add(mesh.GetMaterial()); materials.Add(mesh.GetMaterial());
foreach (var mesh in Renderer.Meshes)
mesh.MaterialIndex = materials.IndexOf(mesh.GetMaterial());
foreach (var tex in Renderer.TextureList) foreach (var tex in Renderer.TextureList)
textures.Add(tex); textures.Add(tex);

View file

@ -270,6 +270,7 @@ namespace Toolbox.Library
if (mesh.MaterialIndex != -1 && Materials.Count > mesh.MaterialIndex) if (mesh.MaterialIndex != -1 && Materials.Count > mesh.MaterialIndex)
{ {
writer.CurrentMaterial = Materials[mesh.MaterialIndex].Text; writer.CurrentMaterial = Materials[mesh.MaterialIndex].Text;
Console.WriteLine($"MaterialIndex {mesh.MaterialIndex } {Materials[mesh.MaterialIndex].Text}");
} }

View file

@ -18,10 +18,10 @@ namespace Toolbox.Library
public class STGenericPolygonGroup public class STGenericPolygonGroup
{ {
public virtual STGenericMaterial Material { get; set; } public virtual STGenericMaterial Material { get; set; } = null;
public int Offset { get; set; } public int Offset { get; set; }
public int MaterialIndex { get; set; } public int MaterialIndex { get; set; } = -1;
public int Index { get; set; } public int Index { get; set; }
public List<int> faces = new List<int>(); public List<int> faces = new List<int>();