load mtxf ADT chunk, no saving/usage yet. credit Adspartan

This commit is contained in:
T1ti
2024-05-30 20:06:45 +02:00
parent 755c6a1e38
commit 063297b5b6
5 changed files with 49 additions and 28 deletions

View File

@@ -74,7 +74,7 @@ struct MHDR
/*020h*/ uint32_t modf; //WMO Positioning Information /*020h*/ uint32_t modf; //WMO Positioning Information
/*024h*/ uint32_t mfbo; // tbc, wotlk; only when flags&1 /*024h*/ uint32_t mfbo; // tbc, wotlk; only when flags&1
/*028h*/ uint32_t mh2o; // wotlk /*028h*/ uint32_t mh2o; // wotlk
/*02Ch*/ uint32_t mtfx; // wotlk /*02Ch*/ uint32_t mtxf; // wotlk
/*030h*/ uint32_t pad4; /*030h*/ uint32_t pad4;
/*034h*/ uint32_t pad5; /*034h*/ uint32_t pad5;
/*038h*/ uint32_t pad6; /*038h*/ uint32_t pad6;
@@ -300,3 +300,15 @@ struct MPHD
uint32_t something; uint32_t something;
uint32_t unused[6]; uint32_t unused[6];
}; };
struct mtxf_entry
{
uint32_t use_cubemap : 1; // do_not_load_specular_or_height_texture_but_use_cubemap
/*
uint32_t : 3;
uint32_t texture_scale : 4; // MOP+ Texture scale here is not an actual "scale".
// Default value is 0 (no extra scaling applied). The values are computed as 1 << SMTextureFlags.texture_scale.
uint32_t : 24;
*/
uint32_t unused : 31;
};

View File

@@ -125,6 +125,8 @@ void MapTile::finishLoading()
std::vector<std::string> mModelFilenames; std::vector<std::string> mModelFilenames;
std::vector<std::string> mWMOFilenames; std::vector<std::string> mWMOFilenames;
// std::map<std::string, mtxf_entry> _mtxf_entries;
uint32_t fourcc; uint32_t fourcc;
uint32_t size; uint32_t size;
@@ -302,34 +304,30 @@ void MapTile::finishLoading()
} }
} }
// - MTFX ---------------------------------------------- // - MTXF ----------------------------------------------
/* if (Header.mtxf != 0)
//! \todo Implement this or just use Terrain Cube maps?
Log << "MTFX offs: " << Header.mtfx << std::endl;
if(Header.mtfx != 0){
Log << "Try to load MTFX" << std::endl;
theFile.seek( Header.mtfx + 0x14 );
theFile.read( &fourcc, 4 );
theFile.read( &size, 4 );
assert( fourcc == 'MTFX' );
{ {
char* lCurPos = reinterpret_cast<char*>( theFile.getPointer() ); theFile.seek(Header.mtxf + 0x14);
char* lEnd = lCurPos + size;
int tCount = 0;
while( lCurPos < lEnd ) {
int temp = 0;
theFile.read(&temp, 4);
Log << "Adding to " << mTextureFilenames[tCount].first << " texture effect: " << temp << std::endl;
mTextureFilenames[tCount++].second = temp;
lCurPos += 4;
}
}
}*/ theFile.read(&fourcc, 4);
theFile.read(&size, 4);
assert(fourcc == 'MTXF');
int count = size / 0x4;
std::vector<mtxf_entry> mtxf_data(count);
theFile.read(mtxf_data.data(), size);
for (int i = 0; i < count; ++i)
{
// _mtxf_entries[mTextureFilenames[i]] = mtxf_data[i];
// only save those with flags set
if (mtxf_data[i].use_cubemap)
_mtxf_entries[mTextureFilenames[i]] = mtxf_data[i];
}
}
// - Done. --------------------------------------------- // - Done. ---------------------------------------------
@@ -374,6 +372,7 @@ void MapTile::finishLoading()
} }
// can be cleared after texture sets are loaded in chunks. // can be cleared after texture sets are loaded in chunks.
mTextureFilenames.clear(); mTextureFilenames.clear();
_mtxf_entries.clear();
theFile.close(); theFile.close();

View File

@@ -199,6 +199,7 @@ private:
std::vector<std::string> mTextureFilenames; std::vector<std::string> mTextureFilenames;
// std::vector<std::string> mModelFilenames; // std::vector<std::string> mModelFilenames;
// std::vector<std::string> mWMOFilenames; // std::vector<std::string> mWMOFilenames;
std::map<std::string, mtxf_entry> _mtxf_entries;
std::vector<uint32_t> uids; std::vector<uint32_t> uids;
tsl::robin_map<AsyncObject*, std::vector<SceneObject*>> object_instances; // only includes M2 and WMO. perhaps a medium common ancestor then? tsl::robin_map<AsyncObject*, std::vector<SceneObject*>> object_instances; // only includes M2 and WMO. perhaps a medium common ancestor then?

View File

@@ -128,6 +128,7 @@ struct scoped_blp_texture_reference
bool operator== (scoped_blp_texture_reference const& other) const; bool operator== (scoped_blp_texture_reference const& other) const;
bool use_cubemap = false;
private: private:
struct Deleter struct Deleter
{ {

View File

@@ -34,7 +34,15 @@ TextureSet::TextureSet (MapChunk* chunk, BlizzardArchive::ClientFile* f, size_t
{ {
f->read (&tmp_entry_mcly[i], sizeof(ENTRY_MCLY)); // f->read (&_layers_info[i], sizeof(ENTRY_MCLY)); f->read (&tmp_entry_mcly[i], sizeof(ENTRY_MCLY)); // f->read (&_layers_info[i], sizeof(ENTRY_MCLY));
textures.emplace_back (tile->mTextureFilenames[tmp_entry_mcly[i].textureID], _context); std::string const& texturefilename = tile->mTextureFilenames[tmp_entry_mcly[i].textureID];
textures.emplace_back (texturefilename, _context);
if (tile->_mtxf_entries.contains(texturefilename))
{
if (tile->_mtxf_entries[texturefilename].use_cubemap)
textures.back().use_cubemap = true;
}
_layers_info[i].effectID = tmp_entry_mcly[i].effectID; _layers_info[i].effectID = tmp_entry_mcly[i].effectID;
_layers_info[i].flags = tmp_entry_mcly[i].flags; _layers_info[i].flags = tmp_entry_mcly[i].flags;
} }