Tools/MeshExtractor:
* Added the option to output debug information on ADTs. * Tweaked rcConfig options and fixed some mistakes about it. * Generate 64 tiles per ADT, this should give us a more accurate mesh on large maps. * Speedup compilation time by moving function bodies from Utils.h to Utils.cpp
This commit is contained in:
1 parent
4c3266c7af
commit
fa57ecddac
8 files changed
+319
-272
No files matched your search
@@ -180,3 +180,253 @@ G3D::Matrix4 Utils::GetWmoDoodadTransformation( DoodadInstance inst, WorldModelD
|
||||
|
||||
return scale * rotation * quatRotation ** translation * rootTransformation;
|
||||
}
|
||||
|
||||
void MapChunkHeader::Read(FILE* stream)
|
||||
{
|
||||
fread(&Flags, sizeof(uint32), 1, stream);
|
||||
fread(&IndexX, sizeof(uint32), 1, stream);
|
||||
fread(&IndexY, sizeof(uint32), 1, stream);
|
||||
fread(&Layers, sizeof(uint32), 1, stream);
|
||||
fread(&DoodadRefs, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCVT, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCNR, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCLY, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCRF, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCAL, sizeof(uint32), 1, stream);
|
||||
fread(&SizeMCAL, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCSH, sizeof(uint32), 1, stream);
|
||||
fread(&SizeMCSH, sizeof(uint32), 1, stream);
|
||||
fread(&AreaId, sizeof(uint32), 1, stream);
|
||||
fread(&MapObjectRefs, sizeof(uint32), 1, stream);
|
||||
fread(&Holes, sizeof(uint32), 1, stream);
|
||||
LowQualityTextureMap = new uint32[4];
|
||||
fread(LowQualityTextureMap, sizeof(uint32), 4, stream);
|
||||
fread(&PredTex, sizeof(uint32), 1, stream);
|
||||
fread(&NumberEffectDoodad, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCSE, sizeof(uint32), 1, stream);
|
||||
fread(&SoundEmitters, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCLQ, sizeof(uint32), 1, stream);
|
||||
fread(&SizeMCLQ, sizeof(uint32), 1, stream);
|
||||
Position = Vector3::Read(stream);
|
||||
fread(&OffsetMCCV, sizeof(uint32), 1, stream);
|
||||
}
|
||||
|
||||
void MHDR::Read(FILE* stream)
|
||||
{
|
||||
fread(&Flags, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMCIN, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMTEX, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMMDX, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMMID, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMWMO, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMWID, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMDDF, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMODF, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMFBO, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMH2O, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetMTFX, sizeof(uint32), 1, stream);
|
||||
}
|
||||
|
||||
void ModelHeader::Read(FILE* stream)
|
||||
{
|
||||
fread(&Magic, sizeof(char), 4, stream);
|
||||
Magic[4] = '\0'; // null-terminate it.
|
||||
fread(&Version, sizeof(uint32), 1, stream);
|
||||
fread(&LengthModelName, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetName, sizeof(uint32), 1, stream);
|
||||
fread(&ModelFlags, sizeof(uint32), 1, stream);
|
||||
fread(&CountGlobalSequences, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetGlobalSequences, sizeof(uint32), 1, stream);
|
||||
fread(&CountAnimations, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetAnimations, sizeof(uint32), 1, stream);
|
||||
fread(&CountAnimationLookup, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetAnimationLookup, sizeof(uint32), 1, stream);
|
||||
fread(&CountBones, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetBones, sizeof(uint32), 1, stream);
|
||||
fread(&CountKeyBoneLookup, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetKeyBoneLookup, sizeof(uint32), 1, stream);
|
||||
fread(&CountVertices, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetVertices, sizeof(uint32), 1, stream);
|
||||
fread(&CountViews, sizeof(uint32), 1, stream);
|
||||
fread(&CountColors, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetColors, sizeof(uint32), 1, stream);
|
||||
fread(&CountTextures, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTextures, sizeof(uint32), 1, stream);
|
||||
fread(&CountTransparency, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTransparency, sizeof(uint32), 1, stream);
|
||||
fread(&CountUvAnimation, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetUvAnimation, sizeof(uint32), 1, stream);
|
||||
fread(&CountTexReplace, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTexReplace, sizeof(uint32), 1, stream);
|
||||
fread(&CountRenderFlags, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetRenderFlags, sizeof(uint32), 1, stream);
|
||||
fread(&CountBoneLookup, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetBoneLookup, sizeof(uint32), 1, stream);
|
||||
fread(&CountTexLookup, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTexLookup, sizeof(uint32), 1, stream);
|
||||
fread(&CountTexUnits, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTexUnits, sizeof(uint32), 1, stream);
|
||||
fread(&CountTransLookup, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTransLookup, sizeof(uint32), 1, stream);
|
||||
fread(&CountUvAnimLookup, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetUvAnimLookup, sizeof(uint32), 1, stream);
|
||||
fread(&CountColors, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetColors, sizeof(uint32), 1, stream);
|
||||
fread(&CountTextures, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTextures, sizeof(uint32), 1, stream);
|
||||
fread(&CountTransparency, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTransparency, sizeof(uint32), 1, stream);
|
||||
fread(&CountUvAnimation, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetUvAnimation, sizeof(uint32), 1, stream);
|
||||
fread(&CountTexReplace, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetTexReplace, sizeof(uint32), 1, stream);
|
||||
VertexBox[0] = Vector3::Read(stream);
|
||||
VertexBox[1] = Vector3::Read(stream);
|
||||
fread(&VertexRadius, sizeof(float), 1, stream);
|
||||
BoundingBox[0] = Vector3::Read(stream);
|
||||
BoundingBox[1] = Vector3::Read(stream);
|
||||
fread(&BoundingRadius, sizeof(float), 1, stream);
|
||||
fread(&CountBoundingTriangles, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetBoundingTriangles, sizeof(uint32), 1, stream);
|
||||
fread(&CountBoundingVertices, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetBoundingVertices, sizeof(uint32), 1, stream);
|
||||
fread(&CountBoundingNormals, sizeof(uint32), 1, stream);
|
||||
fread(&OffsetBoundingNormals, sizeof(uint32), 1, stream);
|
||||
}
|
||||
|
||||
WorldModelHeader WorldModelHeader::Read(FILE* stream)
|
||||
{
|
||||
WorldModelHeader ret;
|
||||
fread(&ret.CountMaterials, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountGroups, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountPortals, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountLights, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountModels, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountDoodads, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountSets, sizeof(uint32), 1, stream);
|
||||
fread(&ret.AmbientColorUnk, sizeof(uint32), 1, stream);
|
||||
fread(&ret.WmoId, sizeof(uint32), 1, stream);
|
||||
ret.BoundingBox[0] = Vector3::Read(stream);
|
||||
ret.BoundingBox[1] = Vector3::Read(stream);
|
||||
fread(&ret.LiquidTypeRelated, sizeof(uint32), 1, stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
DoodadInstance DoodadInstance::Read(FILE* stream)
|
||||
{
|
||||
DoodadInstance ret;
|
||||
fread(&ret.FileOffset, sizeof(uint32), 1, stream);
|
||||
ret.Position = Vector3::Read(stream);
|
||||
fread(&ret.QuatW, sizeof(float), 1, stream);
|
||||
fread(&ret.QuatX, sizeof(float), 1, stream);
|
||||
fread(&ret.QuatY, sizeof(float), 1, stream);
|
||||
fread(&ret.QuatZ, sizeof(float), 1, stream);
|
||||
fread(&ret.Scale, sizeof(float), 1, stream);
|
||||
fread(&ret.LightColor, sizeof(uint32), 1, stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
DoodadSet DoodadSet::Read(FILE* stream)
|
||||
{
|
||||
DoodadSet ret;
|
||||
char name[21];
|
||||
fread(&name, sizeof(char), 20, stream);
|
||||
name[20] = '\0';
|
||||
ret.Name = name;
|
||||
fread(&ret.FirstInstanceIndex, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountInstances, sizeof(uint32), 1, stream);
|
||||
fread(&ret.UnknownZero, sizeof(uint32), 1, stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
LiquidHeader LiquidHeader::Read(FILE* stream)
|
||||
{
|
||||
LiquidHeader ret;
|
||||
fread(&ret.CountXVertices, sizeof(uint32), 1, stream);
|
||||
fread(&ret.CountYVertices, sizeof(uint32), 1, stream);
|
||||
fread(&ret.Width, sizeof(uint32), 1, stream);
|
||||
fread(&ret.Height, sizeof(uint32), 1, stream);
|
||||
ret.BaseLocation = Vector3::Read(stream);
|
||||
fread(&ret.MaterialId, sizeof(uint16), 1, stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
LiquidData LiquidData::Read(FILE* stream, LiquidHeader& header)
|
||||
{
|
||||
LiquidData ret;
|
||||
ret.HeightMap = new float*[header.CountXVertices];
|
||||
for (uint32 i = 0; i < header.CountXVertices; ++i)
|
||||
ret.HeightMap[i] = new float[header.CountYVertices];
|
||||
|
||||
ret.RenderFlags = new uint8*[header.Width];
|
||||
for (uint32 i = 0; i < header.Width; ++i)
|
||||
ret.RenderFlags[i] = new uint8[header.Height];
|
||||
|
||||
for (uint32 y = 0; y < header.CountYVertices; y++)
|
||||
{
|
||||
for (uint32 x = 0; x < header.CountXVertices; x++)
|
||||
{
|
||||
uint32 discard;
|
||||
fread(&discard, sizeof(uint32), 1, stream);
|
||||
float tmp;
|
||||
fread(&tmp, sizeof(float), 1, stream);
|
||||
ret.HeightMap[x][y] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32 y = 0; y < header.Height; y++)
|
||||
{
|
||||
for (uint32 x = 0; x < header.Width; x++)
|
||||
{
|
||||
uint8 tmp;
|
||||
fread(&tmp, sizeof(uint8), 1, stream);
|
||||
ret.RenderFlags[x][y] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
H2ORenderMask H2ORenderMask::Read(FILE* stream)
|
||||
{
|
||||
H2ORenderMask ret;
|
||||
fread(&ret.Mask, sizeof(uint8), 8, stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MCNKLiquidData::IsWater(int x, int y, float height)
|
||||
{
|
||||
if (!Heights)
|
||||
return false;
|
||||
if (!Mask.ShouldRender(x, y))
|
||||
return false;
|
||||
float diff = Heights[x][y] - height;
|
||||
if (diff > Constants::MaxStandableHeight)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
H2OHeader H2OHeader::Read(FILE* stream)
|
||||
{
|
||||
H2OHeader ret;
|
||||
fread(&ret.OffsetInformation, sizeof(uint32), 1, stream);
|
||||
fread(&ret.LayerCount, sizeof(uint32), 1, stream);
|
||||
fread(&ret.OffsetRender, sizeof(uint32), 1, stream);
|
||||
return ret;
|
||||
}
|
||||
|
||||
H2OInformation H2OInformation::Read(FILE* stream)
|
||||
{
|
||||
H2OInformation ret;
|
||||
fread(&ret.LiquidType, sizeof(uint16), 1, stream);
|
||||
fread(&ret.Flags, sizeof(uint16), 1, stream);
|
||||
fread(&ret.HeightLevel1, sizeof(float), 1, stream);
|
||||
fread(&ret.HeightLevel2, sizeof(float), 1, stream);
|
||||
fread(&ret.OffsetX, sizeof(uint8), 1, stream);
|
||||
fread(&ret.OffsetY, sizeof(uint8), 1, stream);
|
||||
fread(&ret.Width, sizeof(uint8), 1, stream);
|
||||
fread(&ret.Height, sizeof(uint8), 1, stream);
|
||||
fread(&ret.OffsetMask2, sizeof(uint32), 1, stream);
|
||||
fread(&ret.OffsetHeightmap, sizeof(uint32), 1, stream);
|
||||
return ret;
|
||||
}
|
||||
Reference in new issue
Block a user