diff options
Diffstat (limited to 'NW4RTools')
-rwxr-xr-x | NW4RTools/ObjImporter.cs | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/NW4RTools/ObjImporter.cs b/NW4RTools/ObjImporter.cs index 384fb66..f6cd945 100755 --- a/NW4RTools/ObjImporter.cs +++ b/NW4RTools/ObjImporter.cs @@ -53,6 +53,8 @@ namespace NW4RTools { public BitArray UsedVertices; public BitArray UsedNormals; public BitArray UsedTexCoords; + + public bool HackFlag; } ShapeContext CurrentShape; @@ -664,6 +666,8 @@ namespace NW4RTools { context.UsedTexCoords = new BitArray(TexCoords.Count); context.UsedNormals = new BitArray(Normals.Count); + context.HackFlag = name.Contains("Path"); + return context; } @@ -779,6 +783,13 @@ namespace NW4RTools { vs.ColorCount[0] = VertexSettings.CompCount.Color4; } + if (context.HackFlag) { + vs.ColorDesc[0] = VertexSettings.DescType.None; + vs.TexCoordDesc[1] = VertexSettings.DescType.Index8; + vs.TexCoordFormat[1] = VertexSettings.CompType.Float32; + vs.TexCoordCount[1] = VertexSettings.CompCount.TexCoord2; + } + uint vd1, vd2, vat1, vat2, vat3; vs.GetDesc(out vd1, out vd2); vs.GetAttrFmt(out vat1, out vat2, out vat3); @@ -795,7 +806,9 @@ namespace NW4RTools { // Lightmap texcoords are auto generated, so we now use 1 here. byte vtxSpecs; - if (usingLightmaps) + if (context.HackFlag) + vtxSpecs = 0 | (1 << 2) | (2 << 4); + else if (usingLightmaps) vtxSpecs = 1 | (1 << 2) | (1 << 4); else vtxSpecs = 0 | (1 << 2) | (1 << 4); @@ -875,7 +888,7 @@ namespace NW4RTools { CurrentModel.VtxNrmData.Add("N_" + CurrentModel.VtxNrmData.Count.ToString(), nrmData); // For lightmaps, before we get baked lighting working - if (usingLightmaps) { + if (usingLightmaps && !context.HackFlag) { var clrData = new VertexClrData(); clrData.ComponentCount = VertexSettings.CompCount.Color4; clrData.ComponentType = VertexSettings.CompType.UInt8; @@ -888,6 +901,20 @@ namespace NW4RTools { shape.ClrData[0] = clrData; } + if (context.HackFlag) { + var tcd2 = new VertexTexCoordData(); + tcd2.ComponentCount = VertexSettings.CompCount.TexCoord2; + tcd2.ComponentType = VertexSettings.CompType.Float32; + tcd2.EntryCount = 1; + tcd2.EntrySize = 8; + tcd2.Fraction = 0; + tcd2.Data = new float[][] { new float[] { 0, 0 } }; + tcd2.Save(); + + shape.TexCoordData[1] = tcd2; + CurrentModel.VtxTexCoordData.Add("T+" + CurrentModel.VtxTexCoordData.Count.ToString(), tcd2); + } + var dl = new DisplayListWriter(); @@ -909,12 +936,14 @@ namespace NW4RTools { dl.WriteUInt16(normalIndexes[tri[7]]); else dl.WriteByte((byte)normalIndexes[tri[7]]); - if (usingLightmaps) + if (usingLightmaps && !context.HackFlag) dl.WriteByte(0); if (u16TcIdx) dl.WriteUInt16(texCoordIndexes[tri[8]]); else dl.WriteByte((byte)texCoordIndexes[tri[8]]); + if (context.HackFlag) + dl.WriteByte(0); if (u16PosIdx) dl.WriteUInt16(posIndexes[tri[3]]); @@ -924,12 +953,14 @@ namespace NW4RTools { dl.WriteUInt16(normalIndexes[tri[4]]); else dl.WriteByte((byte)normalIndexes[tri[4]]); - if (usingLightmaps) + if (usingLightmaps && !context.HackFlag) dl.WriteByte(0); if (u16TcIdx) dl.WriteUInt16(texCoordIndexes[tri[5]]); else dl.WriteByte((byte)texCoordIndexes[tri[5]]); + if (context.HackFlag) + dl.WriteByte(0); if (u16PosIdx) dl.WriteUInt16(posIndexes[tri[0]]); @@ -939,12 +970,14 @@ namespace NW4RTools { dl.WriteUInt16(normalIndexes[tri[1]]); else dl.WriteByte((byte)normalIndexes[tri[1]]); - if (usingLightmaps) + if (usingLightmaps && !context.HackFlag) dl.WriteByte(0); if (u16TcIdx) dl.WriteUInt16(texCoordIndexes[tri[2]]); else dl.WriteByte((byte)texCoordIndexes[tri[2]]); + if (context.HackFlag) + dl.WriteByte(0); } } @@ -960,12 +993,14 @@ namespace NW4RTools { dl.WriteUInt16(normalIndexes[quad[10]]); else dl.WriteByte((byte)normalIndexes[quad[10]]); - if (usingLightmaps) + if (usingLightmaps && !context.HackFlag) dl.WriteByte(0); if (u16TcIdx) dl.WriteUInt16(texCoordIndexes[quad[11]]); else dl.WriteByte((byte)texCoordIndexes[quad[11]]); + if (context.HackFlag) + dl.WriteByte(0); if (u16PosIdx) dl.WriteUInt16(posIndexes[quad[6]]); @@ -975,12 +1010,14 @@ namespace NW4RTools { dl.WriteUInt16(normalIndexes[quad[7]]); else dl.WriteByte((byte)normalIndexes[quad[7]]); - if (usingLightmaps) + if (usingLightmaps && !context.HackFlag) dl.WriteByte(0); if (u16TcIdx) dl.WriteUInt16(texCoordIndexes[quad[8]]); else dl.WriteByte((byte)texCoordIndexes[quad[8]]); + if (context.HackFlag) + dl.WriteByte(0); if (u16PosIdx) dl.WriteUInt16(posIndexes[quad[3]]); @@ -990,12 +1027,14 @@ namespace NW4RTools { dl.WriteUInt16(normalIndexes[quad[4]]); else dl.WriteByte((byte)normalIndexes[quad[4]]); - if (usingLightmaps) + if (usingLightmaps && !context.HackFlag) dl.WriteByte(0); if (u16TcIdx) dl.WriteUInt16(texCoordIndexes[quad[5]]); else dl.WriteByte((byte)texCoordIndexes[quad[5]]); + if (context.HackFlag) + dl.WriteByte(0); if (u16PosIdx) dl.WriteUInt16(posIndexes[quad[0]]); @@ -1005,12 +1044,14 @@ namespace NW4RTools { dl.WriteUInt16(normalIndexes[quad[1]]); else dl.WriteByte((byte)normalIndexes[quad[1]]); - if (usingLightmaps) + if (usingLightmaps && !context.HackFlag) dl.WriteByte(0); if (u16TcIdx) dl.WriteUInt16(texCoordIndexes[quad[2]]); else dl.WriteByte((byte)texCoordIndexes[quad[2]]); + if (context.HackFlag) + dl.WriteByte(0); } } |