diff --git a/Source/Core/GZBuilder/md3/ModelReader.cs b/Source/Core/GZBuilder/md3/ModelReader.cs index 7aec30ccf8c29d6416e27971d19b9e4a0cc976ec..a3a18bef5d3bc6cb4127a1cf3b822e056cbac366 100755 --- a/Source/Core/GZBuilder/md3/ModelReader.cs +++ b/Source/Core/GZBuilder/md3/ModelReader.cs @@ -313,20 +313,6 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 stream_d.Position += 12; // padding[12] long start_d = stream_d.Position; - uint numGroups = 0; - - // some black magic - bool[] used = new bool[256]; - for (int i = 0; i < d3d_numpolys; i++) - { - stream_d.Position = start_d + 16 * i; - stream_d.Position += 14; - byte texnum = br_d.ReadByte(); - used[texnum] = true; - } - - for (int i = 0; i < 256; i++) - if (used[i]) numGroups++; // read a3d header uint a3d_numframes = br_a.ReadUInt16(); @@ -410,27 +396,63 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 vertices[i].nz = -nsum.z / total; } - // wtf is skin groups? - // don't do this for now + Dictionary<int, int> textureGroupRemap = new Dictionary<int, int>(); + int topGrp = 0; + for (int i = 0; i < polys.Length; i++) + { + if (textureGroupRemap.ContainsKey(polys[i].TexNum)) + continue; + textureGroupRemap[polys[i].TexNum] = topGrp++; + } + + if (skins == null) + { + List<WorldVertex> out_verts = new List<WorldVertex>(); + List<int> out_polys = new List<int>(); - List<WorldVertex> out_verts = new List<WorldVertex>(); - List<int> out_polys = new List<int>(); + for (int i = 0; i < polys.Length; i++) + { + for (int j = 0; j < 3; j++) + { + WorldVertex vx = vertices[polys[i].V[j]]; + vx.u = polys[i].S[j]; + vx.v = polys[i].T[j]; + out_polys.Add(out_verts.Count); + out_verts.Add(vx); + } + } - for (int i = 0; i < polys.Length; i++) + CreateMesh(device, ref result, out_verts, out_polys); + result.Skins.Add(""); + } + else { - for (int j = 0; j < 3; j++) + for (int k = 0; k < topGrp; k++) { - WorldVertex vx = vertices[polys[i].V[j]]; - vx.u = polys[i].S[j]; - vx.v = polys[i].T[j]; - out_polys.Add(out_verts.Count); - out_verts.Add(vx); + List<WorldVertex> out_verts = new List<WorldVertex>(); + List<int> out_polys = new List<int>(); + + for (int i = 0; i < polys.Length; i++) + { + + if (textureGroupRemap[polys[i].TexNum] != k) + continue; + + for (int j = 0; j < 3; j++) + { + WorldVertex vx = vertices[polys[i].V[j]]; + vx.u = polys[i].S[j]; + vx.v = polys[i].T[j]; + out_polys.Add(out_verts.Count); + out_verts.Add(vx); + } + } + + CreateMesh(device, ref result, out_verts, out_polys); + result.Skins.Add(skins.ContainsKey(k)?skins[k].ToLowerInvariant():string.Empty); } } - CreateMesh(device, ref result, out_verts, out_polys); - result.Skins.Add(""); - return result; } diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs index 5e1d9080cc2d0eea93b2760d985922714cffb47e..fe650852f42e25eb4133a9e421e2006fbbc00742 100755 --- a/Source/Core/Properties/AssemblyInfo.cs +++ b/Source/Core/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ using CodeImp.DoomBuilder; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.3018")] +[assembly: AssemblyVersion("2.3.0.3022")] [assembly: NeutralResourcesLanguageAttribute("en")] -[assembly: AssemblyHash("e9c83d0")] +[assembly: AssemblyHash("634ba54")] diff --git a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs index d2f49b5cd121181f28cdd9885cbea7d5e6e31090..aa6799efaf1392315e5ac9c9a6e7dae8482b1a0c 100755 --- a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs +++ b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Resources; // Build Number // Revision // -[assembly: AssemblyVersion("2.3.0.3018")] +[assembly: AssemblyVersion("2.3.0.3022")] [assembly: NeutralResourcesLanguageAttribute("en")]