From 367e9a12872102401b8de3515fd34917ddc2b634 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Sun, 3 Nov 2019 18:54:50 -0500 Subject: [PATCH] Fix face format for lm3 meshes --- .../FileFormats/NLG/LM3/LM3_Model.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/File_Format_Library/FileFormats/NLG/LM3/LM3_Model.cs b/File_Format_Library/FileFormats/NLG/LM3/LM3_Model.cs index ae388c51..a1977c51 100644 --- a/File_Format_Library/FileFormats/NLG/LM3/LM3_Model.cs +++ b/File_Format_Library/FileFormats/NLG/LM3/LM3_Model.cs @@ -297,10 +297,6 @@ namespace FirstPlugin.LuigisMansion3 for (int f = 0; f < mesh.IndexCount; f++) polyGroup.faces.Add(reader.ReadUInt16()); break; - case IndexFormat.Index_16_0x2: - for (int f = 0; f < mesh.IndexCount * 4; f++) - polyGroup.faces.Add(reader.ReadUInt16()); - break; /* case IndexFormat.Index_32: for (int f = 0; f < mesh.IndexCount; f++) polyGroup.faces.Add((int)reader.ReadUInt32()); @@ -624,10 +620,17 @@ namespace FirstPlugin.LuigisMansion3 HashID = reader.ReadUInt32(); IndexStartOffset = reader.ReadUInt32(); - IndexCount = reader.ReadUInt32(); + uint indexFlags = reader.ReadUInt32(); + IndexCount = (indexFlags & 0xffffff); + uint type = (indexFlags >> 24); + if (type == 0x80) + IndexFormat = IndexFormat.Index_8; + else + IndexFormat = IndexFormat.Index_16; + + Console.WriteLine($"type {type} indexFlags {indexFlags} IndexCount {IndexCount}"); // IndexFormat = reader.ReadEnum(false); // if (IndexFormat != (IndexFormat)0x8000 && IndexFormat != 0 && IndexFormat != IndexFormat.Index_16_0x2) - IndexFormat = IndexFormat.Index_16; VertexCount = reader.ReadUInt32(); reader.ReadUInt32(); //unknown