mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
a bit formatting
This commit is contained in:
parent
e69880f77e
commit
bd94f257bf
2 changed files with 62 additions and 81 deletions
|
@ -8,17 +8,14 @@ namespace ESM
|
|||
|
||||
void Land::LandData::save(ESMWriter &esm)
|
||||
{
|
||||
// TODO: Make this actually work.
|
||||
|
||||
if (mDataTypes & Land::DATA_VNML) {
|
||||
esm.writeHNT("VNML", mNormals, sizeof(VNML));
|
||||
}
|
||||
|
||||
if (mDataTypes & Land::DATA_VHGT) {
|
||||
VHGT offsets;
|
||||
offsets.mHeightOffset = mHeights[0] / HEIGHT_SCALE;
|
||||
offsets.mUnknown1 = mUnk1;
|
||||
offsets.mUnknown2 = mUnk2;
|
||||
offsets.mUnk1 = mUnk1;
|
||||
offsets.mUnk2 = mUnk2;
|
||||
|
||||
float prevY = mHeights[0], prevX;
|
||||
int number = 0; // avoid multiplication
|
||||
|
@ -41,30 +38,27 @@ void Land::LandData::save(ESMWriter &esm)
|
|||
}
|
||||
esm.writeHNT("VHGT", offsets, sizeof(VHGT));
|
||||
}
|
||||
//esm.writeHNT("WNAM", 0, 81);
|
||||
/* esm.startSubRecord("WNAM");
|
||||
for (int i = 0; i < 81; i++)
|
||||
esm.writeT((char)0x80, 1);
|
||||
esm.endRecord("WNAM");
|
||||
*/
|
||||
if (mDataTypes & Land::DATA_WNAM) {
|
||||
esm.writeHNT("WNAM", mWnam, 81);
|
||||
}
|
||||
|
||||
if (mDataTypes & Land::DATA_VCLR)
|
||||
if (mDataTypes & Land::DATA_VCLR) {
|
||||
esm.writeHNT("VCLR", mColours, 3*LAND_NUM_VERTS);
|
||||
}
|
||||
if (mDataTypes & Land::DATA_VTEX) {
|
||||
uint16_t vtex[256];
|
||||
static uint16_t vtex[LAND_NUM_TEXTURES];
|
||||
transposeTextureData(mTextures, vtex);
|
||||
esm.writeHNT("VTEX", vtex, sizeof(vtex));
|
||||
}
|
||||
}
|
||||
|
||||
void Land::LandData::transposeTextureData(uint16_t *in, uint16_t *out)
|
||||
{
|
||||
int readPos = 0; //bit ugly, but it works
|
||||
for ( int y1 = 0; y1 < 4; y1++ )
|
||||
for ( int x1 = 0; x1 < 4; x1++ )
|
||||
for ( int y2 = 0; y2 < 4; y2++)
|
||||
for ( int x2 = 0; x2 < 4; x2++ )
|
||||
vtex[(y1*4+y2)*16+(x1*4+x2)] = mTextures[readPos++];
|
||||
|
||||
esm.writeHNT("VTEX", vtex, 512);
|
||||
}
|
||||
out[(y1*4+y2)*16+(x1*4+x2)] = in[readPos++];
|
||||
}
|
||||
|
||||
Land::Land()
|
||||
|
@ -175,11 +169,7 @@ void Land::loadData()
|
|||
|
||||
if (mEsm->isNextSub("VNML")) {
|
||||
mEsm->getHExact(mLandData->mNormals, sizeof(VNML));
|
||||
}/*
|
||||
if (mEsm->isNextSub("VNML"))
|
||||
{
|
||||
mEsm->skipHSubSize(12675);
|
||||
} */
|
||||
}
|
||||
|
||||
if (mEsm->isNextSub("VHGT")) {
|
||||
VHGT rawHeights;
|
||||
|
@ -198,33 +188,23 @@ void Land::loadData()
|
|||
mLandData->mHeights[x + y * LAND_SIZE] = tempOffset * HEIGHT_SCALE;
|
||||
}
|
||||
}
|
||||
mLandData->mUnk1 = rawHeights.mUnknown1;
|
||||
mLandData->mUnk2 = rawHeights.mUnknown2;
|
||||
mLandData->mUnk1 = rawHeights.mUnk1;
|
||||
mLandData->mUnk2 = rawHeights.mUnk2;
|
||||
}
|
||||
|
||||
if (mEsm->isNextSub("WNAM"))
|
||||
{
|
||||
if (mEsm->isNextSub("WNAM")) {
|
||||
mEsm->getHExact(mLandData->mWnam, 81);
|
||||
}
|
||||
if (mEsm->isNextSub("VCLR"))
|
||||
{
|
||||
if (mEsm->isNextSub("VCLR")) {
|
||||
mLandData->mUsingColours = true;
|
||||
mEsm->getHExact(&mLandData->mColours, 3*LAND_NUM_VERTS);
|
||||
}else{
|
||||
} else {
|
||||
mLandData->mUsingColours = false;
|
||||
}
|
||||
if (mEsm->isNextSub("VTEX"))
|
||||
{
|
||||
//TODO fix magic numbers
|
||||
uint16_t vtex[256];
|
||||
mEsm->getHExact(&vtex, 512);
|
||||
|
||||
int readPos = 0; //bit ugly, but it works
|
||||
for ( int y1 = 0; y1 < 4; y1++ )
|
||||
for ( int x1 = 0; x1 < 4; x1++ )
|
||||
for ( int y2 = 0; y2 < 4; y2++)
|
||||
for ( int x2 = 0; x2 < 4; x2++ )
|
||||
mLandData->mTextures[(y1*4+y2)*16+(x1*4+x2)] = vtex[readPos++];
|
||||
if (mEsm->isNextSub("VTEX")) {
|
||||
static uint16_t vtex[LAND_NUM_TEXTURES];
|
||||
mEsm->getHExact(&vtex, sizeof(vtex));
|
||||
LandData::transposeTextureData(vtex, mLandData->mTextures);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -61,8 +61,8 @@ struct Land : public Record
|
|||
{
|
||||
float mHeightOffset;
|
||||
int8_t mHeightData[LAND_NUM_VERTS];
|
||||
short mUnknown1;
|
||||
char mUnknown2;
|
||||
short mUnk1;
|
||||
char mUnk2;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
@ -84,6 +84,7 @@ struct Land : public Record
|
|||
uint8_t mUnk2;
|
||||
|
||||
void save(ESMWriter &esm);
|
||||
static void transposeTextureData(uint16_t *in, uint16_t *out);
|
||||
};
|
||||
|
||||
LandData *mLandData;
|
||||
|
|
Loading…
Reference in a new issue