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