Permalink
Browse files

Added low and high res support for ADT holes

  • Loading branch information...
dkrutsko committed May 23, 2017
1 parent 0c8b234 commit 1aa634743fb9348809e4f336b786b6f98dbdb18d
Showing with 65 additions and 8 deletions.
  1. +53 −5 OBJExporterUI/Exporters/OBJ/ADTExporter.cs
  2. +12 −3 WoWFormatLib/Structs/ADT.Struct.cs
@@ -141,12 +141,60 @@ public static void exportADT(string file, BackgroundWorker exportworker = null)
batch.firstFace = (uint)indicelist.Count();
for (int j = 9; j < 145; j++)
// Stupid C# and its structs
var holesHighRes = new byte[8];
holesHighRes[0] = chunk.header.holesHighRes_0;
holesHighRes[1] = chunk.header.holesHighRes_1;
holesHighRes[2] = chunk.header.holesHighRes_2;
holesHighRes[3] = chunk.header.holesHighRes_3;
holesHighRes[4] = chunk.header.holesHighRes_4;
holesHighRes[5] = chunk.header.holesHighRes_5;
holesHighRes[6] = chunk.header.holesHighRes_6;
holesHighRes[7] = chunk.header.holesHighRes_7;
for (int j = 9, xx = 0, yy = 0; j < 145; j++, xx++)
{
indicelist.AddRange(new Int32[] { off + j + 8, off + j - 9, off + j });
indicelist.AddRange(new Int32[] { off + j - 9, off + j - 8, off + j });
indicelist.AddRange(new Int32[] { off + j - 8, off + j + 9, off + j });
indicelist.AddRange(new Int32[] { off + j + 9, off + j + 8, off + j });
if (xx >= 8) { xx = 0; ++yy; }
bool isHole = true;
// Check if chunk is using low-res holes
if ((chunk.header.flags & 0x10000) == 0)
{
// Calculate current hole number
var currentHole = (int) Math.Pow (2,
Math.Floor (xx / 2f) * 1f +
Math.Floor (yy / 2f) * 4f);
// Check if current hole number should be a hole
if ((chunk.header.holesLowRes & currentHole) == 0)
{
isHole = false;
}
}
else
{
// Check if current section is a hole
if (((holesHighRes[yy] >> xx) & 1) == 0)
{
isHole = false;
}
}
if (!isHole)
{
indicelist.AddRange(new Int32[] { off + j + 8, off + j - 9, off + j });
indicelist.AddRange(new Int32[] { off + j - 9, off + j - 8, off + j });
indicelist.AddRange(new Int32[] { off + j - 8, off + j + 9, off + j });
indicelist.AddRange(new Int32[] { off + j + 9, off + j + 8, off + j });
// Generates quads instead of 4x triangles
/*
indicelist.AddRange(new Int32[] { off + j + 8, off + j - 9, off + j - 8 });
indicelist.AddRange(new Int32[] { off + j - 8, off + j + 9, off + j + 8 });
*/
}
if ((j + 1) % (9 + 8) == 0) j += 9;
}
@@ -45,8 +45,16 @@ public struct MCNKheader
public uint indexY;
public uint nLayers;
public uint nDoodadRefs;
public uint ofsMCVT;
public uint ofsMCNR;
public byte holesHighRes_0;
public byte holesHighRes_1;
public byte holesHighRes_2;
public byte holesHighRes_3;
public byte holesHighRes_4;
public byte holesHighRes_5;
public byte holesHighRes_6;
public byte holesHighRes_7;
// public uint ofsMCVT;
// public uint ofsMCNR;
public uint ofsMCLY;
public uint ofsMCRF;
public uint ofsMCAL;
@@ -55,7 +63,8 @@ public struct MCNKheader
public uint sizeShadows;
public uint areaID;
public uint nMapObjRefs;
public uint holes;
public ushort holesLowRes;
public ushort unknownPad;
public short lowQualityTexturingMap_0;
public short lowQualityTexturingMap_1;
public short lowQualityTexturingMap_2;

0 comments on commit 1aa6347

Please sign in to comment.